[Pkg-javascript-commits] [node-iconv] 01/10: Imported Upstream version 2.1.8
Jérémy Lal
kapouer at moszumanska.debian.org
Sun Jun 14 19:35:18 UTC 2015
This is an automated email from the git hooks/post-receive script.
kapouer pushed a commit to branch master
in repository node-iconv.
commit 62f5565c0150391db3f779d2a569e540ba91944d
Author: Jérémy Lal <kapouer at melix.org>
Date: Sun Jun 14 19:43:00 2015 +0200
Imported Upstream version 2.1.8
---
README.md | 63 ++-
binding.gyp | 19 +-
deps/libiconv/src/iconv.c | 1118 -------------------------------------
deps/libiconv/src/iconv_no_i18n.c | 2 -
lib/iconv.js | 2 +
package.json | 4 +-
src/binding.cc | 17 +-
support/config.h | 2 +-
test/test-basic.js | 13 +
test/test-big-buffer.js | 2 +
test/test-stream.js | 2 +
11 files changed, 103 insertions(+), 1141 deletions(-)
diff --git a/README.md b/README.md
index 23066cd..4dc6517 100644
--- a/README.md
+++ b/README.md
@@ -2,8 +2,65 @@
Text recoding in JavaScript for fun and profit!
-node-iconv may or may not work on Windows. Please try it and report any issues
-you have.
+## Supported encodings
+
+ European languages
+ ASCII, ISO-8859-{1,2,3,4,5,7,9,10,13,14,15,16},
+ KOI8-R, KOI8-U, KOI8-RU,
+ CP{437,737,775,850,852,853,855,857,858,860,861,863,865,866,869}
+ CP{1125,1250,1251,1252,1253,1254,1257}
+ Mac{Roman,CentralEurope,Iceland,Croatian,Romania},
+ Mac{Cyrillic,Ukraine,Greek,Turkish},
+ Macintosh
+ Semitic languages
+ ISO-8859-{6,8}, CP{1255,1256}, CP862, CP864, Mac{Hebrew,Arabic}
+ Japanese
+ EUC-JP, SHIFT_JIS, CP932, ISO-2022-JP, ISO-2022-JP-2, ISO-2022-JP-1
+ EUC-JISX0213, Shift_JISX0213, ISO-2022-JP-3
+ Chinese
+ EUC-CN, HZ, GBK, CP936, GB18030, EUC-TW, BIG5, CP950, BIG5-HKSCS,
+ BIG5-HKSCS:2004, BIG5-HKSCS:2001, BIG5-HKSCS:1999, ISO-2022-CN,
+ ISO-2022-CN-EXT, BIG5-2003 (experimental)
+ Korean
+ EUC-KR, CP949, ISO-2022-KR, JOHAB
+ Turkmen
+ TDS565
+ Armenian
+ ARMSCII-8
+ Georgian
+ Georgian-Academy, Georgian-PS
+ Tajik
+ KOI8-T
+ Kazakh
+ PT154, RK1048
+ Thai
+ ISO-8859-11, TIS-620, CP874, MacThai
+ Laotian
+ MuleLao-1, CP1133
+ Vietnamese
+ VISCII, TCVN, CP1258
+ Platform specifics
+ HP-ROMAN8, NEXTSTEP, ATARIST, RISCOS-LATIN1
+ Full Unicode
+ UTF-8
+ UCS-2, UCS-2BE, UCS-2LE
+ UCS-4, UCS-4BE, UCS-4LE
+ UTF-16, UTF-16BE, UTF-16LE
+ UTF-32, UTF-32BE, UTF-32LE
+ UTF-7
+ C99, JAVA
+ Full Unicode, in terms of `uint16_t` or `uint32_t`
+ (with machine dependent endianness and alignment)
+ UCS-2-INTERNAL, UCS-4-INTERNAL
+ Locale dependent, in terms of `char` or `wchar_t`
+ (with machine dependent endianness and alignment, and with OS and
+ locale dependent semantics)
+ char, wchar_t
+ The empty encoding name "" is equivalent to "char": it denotes the
+ locale dependent character encoding.
+
+If you don't need the full gamut of encodings, consider using [iconv-lite][].
+It supports most common encodings and doesn't require a compiler to install.
## Installing with [npm](http://npmjs.org/)
@@ -102,3 +159,5 @@ Example usage:
EINVAL is raised when the input ends in a partial character sequence. This is a
feature, not a bug.
+
+[iconv-lite]: https://www.npmjs.org/package/iconv-lite
diff --git a/binding.gyp b/binding.gyp
index 8cfc1ff..f3d0940 100644
--- a/binding.gyp
+++ b/binding.gyp
@@ -26,14 +26,7 @@
'direct_dependent_settings': {
'include_dirs': ['support'],
},
- 'defines': [
- 'ICONV_CONST=const',
- 'USE_AIX=1',
- 'USE_DOS=1',
- 'USE_EXTRA=1',
- 'USE_OSF1=1',
- 'LIBDIR="."', # not actually used
- ],
+ 'defines': ['ICONV_CONST=const', 'ENABLE_EXTRA=1'],
'include_dirs': [
'deps/libiconv/srclib',
'support',
@@ -47,6 +40,16 @@
'cflags!': ['-W', '-Wall', '-Wextra'],
}],
],
+ 'msvs_settings': {
+ 'VCCLCompilerTool': {
+ 'DisableSpecificWarnings': [
+ '4018', # Signed/unsigned comparison.
+ '4090', # Const/non-const mismatch.
+ '4244', # Narrowing cast.
+ '4267', # Narrowing cast.
+ ],
+ },
+ },
'xcode_settings': {
'WARNING_CFLAGS!': ['-W', '-Wall', '-Wextra'],
'WARNING_CFLAGS': [
diff --git a/deps/libiconv/src/iconv.c b/deps/libiconv/src/iconv.c
deleted file mode 100644
index 825ef22..0000000
--- a/deps/libiconv/src/iconv.c
+++ /dev/null
@@ -1,1118 +0,0 @@
-/* Copyright (C) 2000-2009, 2011 Free Software Foundation, Inc.
- This file is part of the GNU LIBICONV Library.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-#include "config.h"
-#ifndef ICONV_CONST
-# define ICONV_CONST
-#endif
-
-#include <limits.h>
-#include <stddef.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <iconv.h>
-#include <errno.h>
-#include <locale.h>
-#include <fcntl.h>
-
-/* Ensure that iconv_no_i18n does not depend on libintl. */
-#ifdef NO_I18N
-# undef ENABLE_NLS
-# undef ENABLE_RELOCATABLE
-#endif
-
-#include "binary-io.h"
-#include "progname.h"
-#include "relocatable.h"
-#include "safe-read.h"
-#include "xalloc.h"
-#include "uniwidth.h"
-#include "uniwidth/cjk.h"
-
-/* Ensure that iconv_no_i18n does not depend on libintl. */
-#ifdef NO_I18N
-#include <stdarg.h>
-static void
-error (int status, int errnum, const char *message, ...)
-{
- va_list args;
-
- fflush(stdout);
- fprintf(stderr,"%s: ",program_name);
- va_start(args,message);
- vfprintf(stderr,message,args);
- va_end(args);
- if (errnum) {
- const char *s = strerror(errnum);
- if (s == NULL)
- s = "Unknown system error";
- }
- putc('\n',stderr);
- fflush(stderr);
- if (status)
- exit(status);
-}
-#else
-# include "error.h"
-#endif
-
-#include "gettext.h"
-
-#define _(str) gettext(str)
-
-/* Ensure that iconv_no_i18n does not depend on libintl. */
-#ifdef NO_I18N
-# define xmalloc malloc
-# define xalloc_die abort
-#endif
-
-/* Locale independent test for a decimal digit.
- Argument can be 'char' or 'unsigned char'. (Whereas the argument of
- <ctype.h> isdigit must be an 'unsigned char'.) */
-#undef isdigit
-#define isdigit(c) ((unsigned int) ((c) - '0') < 10)
-
-/* Locale independent test for a printable character.
- Argument can be 'char' or 'unsigned char'. (Whereas the argument of
- <ctype.h> isdigit must be an 'unsigned char'.) */
-#define c_isprint(c) ((c) >= ' ' && (c) <= '~')
-
-/* ========================================================================= */
-
-static int discard_unconvertible = 0;
-static int silent = 0;
-
-static void usage (int exitcode)
-{
- if (exitcode != 0) {
- const char* helpstring1 =
- /* TRANSLATORS: The first line of the short usage message. */
- _("Usage: iconv [-c] [-s] [-f fromcode] [-t tocode] [file ...]");
- const char* helpstring2 =
- /* TRANSLATORS: The second line of the short usage message.
- Align it correctly against the first line. */
- _("or: iconv -l");
- fprintf(stderr, "%s\n%s\n", helpstring1, helpstring2);
- fprintf(stderr, _("Try `%s --help' for more information.\n"), program_name);
- } else {
- /* xgettext: no-wrap */
- /* TRANSLATORS: The first line of the long usage message.
- The %s placeholder expands to the program name. */
- printf(_("\
-Usage: %s [OPTION...] [-f ENCODING] [-t ENCODING] [INPUTFILE...]\n"),
- program_name);
- /* xgettext: no-wrap */
- /* TRANSLATORS: The second line of the long usage message.
- Align it correctly against the first line.
- The %s placeholder expands to the program name. */
- printf(_("\
-or: %s -l\n"),
- program_name);
- printf("\n");
- /* xgettext: no-wrap */
- /* TRANSLATORS: Description of the iconv program. */
- printf(_("\
-Converts text from one encoding to another encoding.\n"));
- printf("\n");
- /* xgettext: no-wrap */
- printf(_("\
-Options controlling the input and output format:\n"));
- /* xgettext: no-wrap */
- printf(_("\
- -f ENCODING, --from-code=ENCODING\n\
- the encoding of the input\n"));
- /* xgettext: no-wrap */
- printf(_("\
- -t ENCODING, --to-code=ENCODING\n\
- the encoding of the output\n"));
- printf("\n");
- /* xgettext: no-wrap */
- printf(_("\
-Options controlling conversion problems:\n"));
- /* xgettext: no-wrap */
- printf(_("\
- -c discard unconvertible characters\n"));
- /* xgettext: no-wrap */
- printf(_("\
- --unicode-subst=FORMATSTRING\n\
- substitution for unconvertible Unicode characters\n"));
- /* xgettext: no-wrap */
- printf(_("\
- --byte-subst=FORMATSTRING substitution for unconvertible bytes\n"));
- /* xgettext: no-wrap */
- printf(_("\
- --widechar-subst=FORMATSTRING\n\
- substitution for unconvertible wide characters\n"));
- printf("\n");
- /* xgettext: no-wrap */
- printf(_("\
-Options controlling error output:\n"));
- /* xgettext: no-wrap */
- printf(_("\
- -s, --silent suppress error messages about conversion problems\n"));
- printf("\n");
- /* xgettext: no-wrap */
- printf(_("\
-Informative output:\n"));
- /* xgettext: no-wrap */
- printf(_("\
- -l, --list list the supported encodings\n"));
- /* xgettext: no-wrap */
- printf(_("\
- --help display this help and exit\n"));
- /* xgettext: no-wrap */
- printf(_("\
- --version output version information and exit\n"));
- printf("\n");
- /* TRANSLATORS: The placeholder indicates the bug-reporting address
- for this package. Please add _another line_ saying
- "Report translation bugs to <...>\n" with the address for translation
- bugs (typically your translation team's web or email address). */
- fputs(_("Report bugs to <bug-gnu-libiconv at gnu.org>.\n"),stdout);
- }
- exit(exitcode);
-}
-
-static void print_version (void)
-{
- printf("iconv (GNU libiconv %d.%d)\n",
- _libiconv_version >> 8, _libiconv_version & 0xff);
- printf("Copyright (C) %s Free Software Foundation, Inc.\n", "2000-2011");
- /* xgettext: no-wrap */
- fputs (_("\
-License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\n\
-This is free software: you are free to change and redistribute it.\n\
-There is NO WARRANTY, to the extent permitted by law.\n\
-"),stdout);
- /* TRANSLATORS: The %s placeholder expands to an author's name. */
- printf(_("Written by %s.\n"),"Bruno Haible");
- exit(EXIT_SUCCESS);
-}
-
-static int print_one (unsigned int namescount, const char * const * names,
- void* data)
-{
- unsigned int i;
- (void)data;
- for (i = 0; i < namescount; i++) {
- if (i > 0)
- putc(' ',stdout);
- fputs(names[i],stdout);
- }
- putc('\n',stdout);
- return 0;
-}
-
-/* ========================================================================= */
-
-/* Line number and column position. */
-static unsigned int line;
-static unsigned int column;
-static const char* cjkcode;
-/* Update the line number and column position after a character was
- successfully converted. */
-static void update_line_column (unsigned int uc, void* data)
-{
- if (uc == 0x000A) {
- line++;
- column = 0;
- } else {
- int width = uc_width(uc, cjkcode);
- if (width >= 0)
- column += width;
- else if (uc == 0x0009)
- column += 8 - (column % 8);
- }
-}
-
-/* ========================================================================= */
-
-/* Production of placeholder strings as fallback for unconvertible
- characters. */
-
-/* Check that the argument is a format string taking either no argument
- or exactly one unsigned integer argument. Returns the maximum output
- size of the format string. */
-static size_t check_subst_formatstring (const char *format, const char *param_name)
-{
- /* C format strings are described in POSIX (IEEE P1003.1 2001), section
- XSH 3 fprintf(). See also Linux fprintf(3) manual page.
- For simplicity, we don't accept
- - the '%m$' reordering syntax,
- - the 'I' flag,
- - width specifications referring to an argument,
- - precision specifications referring to an argument,
- - size specifiers,
- - format specifiers other than 'o', 'u', 'x', 'X'.
- What remains?
- A directive
- - starts with '%',
- - is optionally followed by any of the characters '#', '0', '-', ' ',
- '+', "'", each of which acts as a flag,
- - is optionally followed by a width specification: a nonempty digit
- sequence,
- - is optionally followed by '.' and a precision specification: a
- nonempty digit sequence,
- - is finished by a specifier
- - '%', that needs no argument,
- - 'o', 'u', 'x', 'X', that need an unsigned integer argument.
- */
- size_t maxsize = 0;
- unsigned int unnumbered_arg_count = 0;
-
- for (; *format != '\0';) {
- if (*format++ == '%') {
- /* A directive. */
- unsigned int width = 0;
- unsigned int precision = 0;
- unsigned int length;
- /* Parse flags. */
- for (;;) {
- if (*format == ' ' || *format == '+' || *format == '-'
- || *format == '#' || *format == '0' || *format == '\'')
- format++;
- else
- break;
- }
- /* Parse width. */
- if (*format == '*')
- error(EXIT_FAILURE,0,
- /* TRANSLATORS: An error message.
- The %s placeholder expands to a command-line option. */
- _("%s argument: A format directive with a variable width is not allowed here."),
- param_name);
- if (isdigit (*format)) {
- do {
- width = 10*width + (*format - '0');
- format++;
- } while (isdigit (*format));
- }
- /* Parse precision. */
- if (*format == '.') {
- format++;
- if (*format == '*')
- error(EXIT_FAILURE,0,
- /* TRANSLATORS: An error message.
- The %s placeholder expands to a command-line option. */
- _("%s argument: A format directive with a variable precision is not allowed here."),
- param_name);
- if (isdigit (*format)) {
- do {
- precision = 10*precision + (*format - '0');
- format++;
- } while (isdigit (*format));
- }
- }
- /* Parse size. */
- switch (*format) {
- case 'h': case 'l': case 'L': case 'q':
- case 'j': case 'z': case 'Z': case 't':
- error(EXIT_FAILURE,0,
- /* TRANSLATORS: An error message.
- The %s placeholder expands to a command-line option. */
- _("%s argument: A format directive with a size is not allowed here."),
- param_name);
- }
- /* Parse end of directive. */
- switch (*format) {
- case '%':
- length = 1;
- break;
- case 'u': case 'o': case 'x': case 'X':
- if (*format == 'u') {
- length = (unsigned int) (sizeof (unsigned int) * CHAR_BIT
- * 0.30103 /* binary -> decimal */
- )
- + 1; /* turn floor into ceil */
- if (length < precision)
- length = precision;
- length *= 2; /* estimate for FLAG_GROUP */
- length += 1; /* account for leading sign */
- } else if (*format == 'o') {
- length = (unsigned int) (sizeof (unsigned int) * CHAR_BIT
- * 0.333334 /* binary -> octal */
- )
- + 1; /* turn floor into ceil */
- if (length < precision)
- length = precision;
- length += 1; /* account for leading sign */
- } else { /* 'x', 'X' */
- length = (unsigned int) (sizeof (unsigned int) * CHAR_BIT
- * 0.25 /* binary -> hexadecimal */
- )
- + 1; /* turn floor into ceil */
- if (length < precision)
- length = precision;
- length += 2; /* account for leading sign or alternate form */
- }
- unnumbered_arg_count++;
- break;
- default:
- if (*format == '\0')
- error(EXIT_FAILURE,0,
- /* TRANSLATORS: An error message.
- The %s placeholder expands to a command-line option. */
- _("%s argument: The string ends in the middle of a directive."),
- param_name);
- else if (c_isprint(*format))
- error(EXIT_FAILURE,0,
- /* TRANSLATORS: An error message.
- The %s placeholder expands to a command-line option.
- The %c placeholder expands to an unknown format directive. */
- _("%s argument: The character '%c' is not a valid conversion specifier."),
- param_name,*format);
- else
- error(EXIT_FAILURE,0,
- /* TRANSLATORS: An error message.
- The %s placeholder expands to a command-line option. */
- _("%s argument: The character that terminates the format directive is not a valid conversion specifier."),
- param_name);
- abort(); /*NOTREACHED*/
- }
- format++;
- if (length < width)
- length = width;
- maxsize += length;
- } else
- maxsize++;
- }
- if (unnumbered_arg_count > 1)
- error(EXIT_FAILURE,0,
- /* TRANSLATORS: An error message.
- The %s placeholder expands to a command-line option.
- The %u placeholder expands to the number of arguments consumed by the format string. */
- ngettext("%s argument: The format string consumes more than one argument: %u argument.",
- "%s argument: The format string consumes more than one argument: %u arguments.",
- unnumbered_arg_count),
- param_name,unnumbered_arg_count);
- return maxsize;
-}
-
-/* Format strings. */
-static const char* ilseq_byte_subst;
-static const char* ilseq_wchar_subst;
-static const char* ilseq_unicode_subst;
-
-/* Maximum result size for each format string. */
-static size_t ilseq_byte_subst_size;
-static size_t ilseq_wchar_subst_size;
-static size_t ilseq_unicode_subst_size;
-
-/* Buffer of size ilseq_byte_subst_size+1. */
-static char* ilseq_byte_subst_buffer;
-#if HAVE_WCHAR_T
-/* Buffer of size ilseq_wchar_subst_size+1. */
-static char* ilseq_wchar_subst_buffer;
-#endif
-/* Buffer of size ilseq_unicode_subst_size+1. */
-static char* ilseq_unicode_subst_buffer;
-
-/* Auxiliary variables for subst_mb_to_uc_fallback. */
-/* Converter from locale encoding to UCS-4. */
-static iconv_t subst_mb_to_uc_cd;
-/* Buffer of size ilseq_byte_subst_size. */
-static unsigned int* subst_mb_to_uc_temp_buffer;
-
-static void subst_mb_to_uc_fallback
- (const char* inbuf, size_t inbufsize,
- void (*write_replacement) (const unsigned int *buf, size_t buflen,
- void* callback_arg),
- void* callback_arg,
- void* data)
-{
- for (; inbufsize > 0; inbuf++, inbufsize--) {
- const char* inptr;
- size_t inbytesleft;
- char* outptr;
- size_t outbytesleft;
- sprintf(ilseq_byte_subst_buffer,
- ilseq_byte_subst, (unsigned int)(unsigned char)*inbuf);
- inptr = ilseq_byte_subst_buffer;
- inbytesleft = strlen(ilseq_byte_subst_buffer);
- outptr = (char*)subst_mb_to_uc_temp_buffer;
- outbytesleft = ilseq_byte_subst_size*sizeof(unsigned int);
- iconv(subst_mb_to_uc_cd,NULL,NULL,NULL,NULL);
- if (iconv(subst_mb_to_uc_cd, (ICONV_CONST char**)&inptr,&inbytesleft, &outptr,&outbytesleft)
- == (size_t)(-1)
- || iconv(subst_mb_to_uc_cd, NULL,NULL, &outptr,&outbytesleft)
- == (size_t)(-1))
- error(EXIT_FAILURE,0,
- /* TRANSLATORS: An error message.
- The %s placeholder expands to a piece of text, specified through --byte-subst. */
- _("cannot convert byte substitution to Unicode: %s"),
- ilseq_byte_subst_buffer);
- if (!(outbytesleft%sizeof(unsigned int) == 0))
- abort();
- write_replacement(subst_mb_to_uc_temp_buffer,
- ilseq_byte_subst_size-(outbytesleft/sizeof(unsigned int)),
- callback_arg);
- }
-}
-
-/* Auxiliary variables for subst_uc_to_mb_fallback. */
-/* Converter from locale encoding to target encoding. */
-static iconv_t subst_uc_to_mb_cd;
-/* Buffer of size ilseq_unicode_subst_size*4. */
-static char* subst_uc_to_mb_temp_buffer;
-
-static void subst_uc_to_mb_fallback
- (unsigned int code,
- void (*write_replacement) (const char *buf, size_t buflen,
- void* callback_arg),
- void* callback_arg,
- void* data)
-{
- const char* inptr;
- size_t inbytesleft;
- char* outptr;
- size_t outbytesleft;
- sprintf(ilseq_unicode_subst_buffer, ilseq_unicode_subst, code);
- inptr = ilseq_unicode_subst_buffer;
- inbytesleft = strlen(ilseq_unicode_subst_buffer);
- outptr = subst_uc_to_mb_temp_buffer;
- outbytesleft = ilseq_unicode_subst_size*4;
- iconv(subst_uc_to_mb_cd,NULL,NULL,NULL,NULL);
- if (iconv(subst_uc_to_mb_cd, (ICONV_CONST char**)&inptr,&inbytesleft, &outptr,&outbytesleft)
- == (size_t)(-1)
- || iconv(subst_uc_to_mb_cd, NULL,NULL, &outptr,&outbytesleft)
- == (size_t)(-1))
- error(EXIT_FAILURE,0,
- /* TRANSLATORS: An error message.
- The %s placeholder expands to a piece of text, specified through --unicode-subst. */
- _("cannot convert unicode substitution to target encoding: %s"),
- ilseq_unicode_subst_buffer);
- write_replacement(subst_uc_to_mb_temp_buffer,
- ilseq_unicode_subst_size*4-outbytesleft,
- callback_arg);
-}
-
-#if HAVE_WCHAR_T
-
-/* Auxiliary variables for subst_mb_to_wc_fallback. */
-/* Converter from locale encoding to wchar_t. */
-static iconv_t subst_mb_to_wc_cd;
-/* Buffer of size ilseq_byte_subst_size. */
-static wchar_t* subst_mb_to_wc_temp_buffer;
-
-static void subst_mb_to_wc_fallback
- (const char* inbuf, size_t inbufsize,
- void (*write_replacement) (const wchar_t *buf, size_t buflen,
- void* callback_arg),
- void* callback_arg,
- void* data)
-{
- for (; inbufsize > 0; inbuf++, inbufsize--) {
- const char* inptr;
- size_t inbytesleft;
- char* outptr;
- size_t outbytesleft;
- sprintf(ilseq_byte_subst_buffer,
- ilseq_byte_subst, (unsigned int)(unsigned char)*inbuf);
- inptr = ilseq_byte_subst_buffer;
- inbytesleft = strlen(ilseq_byte_subst_buffer);
- outptr = (char*)subst_mb_to_wc_temp_buffer;
- outbytesleft = ilseq_byte_subst_size*sizeof(wchar_t);
- iconv(subst_mb_to_wc_cd,NULL,NULL,NULL,NULL);
- if (iconv(subst_mb_to_wc_cd, (ICONV_CONST char**)&inptr,&inbytesleft, &outptr,&outbytesleft)
- == (size_t)(-1)
- || iconv(subst_mb_to_wc_cd, NULL,NULL, &outptr,&outbytesleft)
- == (size_t)(-1))
- error(EXIT_FAILURE,0,
- /* TRANSLATORS: An error message.
- The %s placeholder expands to a piece of text, specified through --byte-subst. */
- _("cannot convert byte substitution to wide string: %s"),
- ilseq_byte_subst_buffer);
- if (!(outbytesleft%sizeof(wchar_t) == 0))
- abort();
- write_replacement(subst_mb_to_wc_temp_buffer,
- ilseq_byte_subst_size-(outbytesleft/sizeof(wchar_t)),
- callback_arg);
- }
-}
-
-/* Auxiliary variables for subst_wc_to_mb_fallback. */
-/* Converter from locale encoding to target encoding. */
-static iconv_t subst_wc_to_mb_cd;
-/* Buffer of size ilseq_wchar_subst_size*4.
- Hardcode factor 4, because MB_LEN_MAX is not reliable on some platforms. */
-static char* subst_wc_to_mb_temp_buffer;
-
-static void subst_wc_to_mb_fallback
- (wchar_t code,
- void (*write_replacement) (const char *buf, size_t buflen,
- void* callback_arg),
- void* callback_arg,
- void* data)
-{
- const char* inptr;
- size_t inbytesleft;
- char* outptr;
- size_t outbytesleft;
- sprintf(ilseq_wchar_subst_buffer, ilseq_wchar_subst, (unsigned int) code);
- inptr = ilseq_wchar_subst_buffer;
- inbytesleft = strlen(ilseq_wchar_subst_buffer);
- outptr = subst_wc_to_mb_temp_buffer;
- outbytesleft = ilseq_wchar_subst_size*4;
- iconv(subst_wc_to_mb_cd,NULL,NULL,NULL,NULL);
- if (iconv(subst_wc_to_mb_cd, (ICONV_CONST char**)&inptr,&inbytesleft, &outptr,&outbytesleft)
- == (size_t)(-1)
- || iconv(subst_wc_to_mb_cd, NULL,NULL, &outptr,&outbytesleft)
- == (size_t)(-1))
- error(EXIT_FAILURE,0,
- /* TRANSLATORS: An error message.
- The %s placeholder expands to a piece of text, specified through --widechar-subst. */
- _("cannot convert widechar substitution to target encoding: %s"),
- ilseq_wchar_subst_buffer);
- write_replacement(subst_wc_to_mb_temp_buffer,
- ilseq_wchar_subst_size*4-outbytesleft,
- callback_arg);
-}
-
-#else
-
-#define subst_mb_to_wc_fallback NULL
-#define subst_wc_to_mb_fallback NULL
-
-#endif
-
-/* Auxiliary variables for subst_mb_to_mb_fallback. */
-/* Converter from locale encoding to target encoding. */
-static iconv_t subst_mb_to_mb_cd;
-/* Buffer of size ilseq_byte_subst_size*4. */
-static char* subst_mb_to_mb_temp_buffer;
-
-static void subst_mb_to_mb_fallback (const char* inbuf, size_t inbufsize)
-{
- for (; inbufsize > 0; inbuf++, inbufsize--) {
- const char* inptr;
- size_t inbytesleft;
- char* outptr;
- size_t outbytesleft;
- sprintf(ilseq_byte_subst_buffer,
- ilseq_byte_subst, (unsigned int)(unsigned char)*inbuf);
- inptr = ilseq_byte_subst_buffer;
- inbytesleft = strlen(ilseq_byte_subst_buffer);
- outptr = subst_mb_to_mb_temp_buffer;
- outbytesleft = ilseq_byte_subst_size*4;
- iconv(subst_mb_to_mb_cd,NULL,NULL,NULL,NULL);
- if (iconv(subst_mb_to_mb_cd, (ICONV_CONST char**)&inptr,&inbytesleft, &outptr,&outbytesleft)
- == (size_t)(-1)
- || iconv(subst_mb_to_mb_cd, NULL,NULL, &outptr,&outbytesleft)
- == (size_t)(-1))
- error(EXIT_FAILURE,0,
- /* TRANSLATORS: An error message.
- The %s placeholder expands to a piece of text, specified through --byte-subst. */
- _("cannot convert byte substitution to target encoding: %s"),
- ilseq_byte_subst_buffer);
- fwrite(subst_mb_to_mb_temp_buffer,1,ilseq_byte_subst_size*4-outbytesleft,
- stdout);
- }
-}
-
-/* ========================================================================= */
-
-/* Error messages during conversion. */
-
-static void conversion_error_EILSEQ (const char* infilename)
-{
- fflush(stdout);
- if (column > 0)
- putc('\n',stderr);
- error(0,0,
- /* TRANSLATORS: An error message.
- The placeholders expand to the input file name, a line number, and a column number. */
- _("%s:%u:%u: cannot convert"),
- infilename,line,column);
-}
-
-static void conversion_error_EINVAL (const char* infilename)
-{
- fflush(stdout);
- if (column > 0)
- putc('\n',stderr);
- error(0,0,
- /* TRANSLATORS: An error message.
- The placeholders expand to the input file name, a line number, and a column number.
- A "shift sequence" is a sequence of bytes that changes the state of the converter;
- this concept exists only for "stateful" encodings like ISO-2022-JP. */
- _("%s:%u:%u: incomplete character or shift sequence"),
- infilename,line,column);
-}
-
-static void conversion_error_other (int errnum, const char* infilename)
-{
- fflush(stdout);
- if (column > 0)
- putc('\n',stderr);
- error(0,errnum,
- /* TRANSLATORS: The first part of an error message.
- It is followed by a colon and a detail message.
- The placeholders expand to the input file name, a line number, and a column number. */
- _("%s:%u:%u"),
- infilename,line,column);
-}
-
-/* Convert the input given in infile. */
-
-static int convert (iconv_t cd, int infile, const char* infilename)
-{
- char inbuf[4096+4096];
- size_t inbufrest = 0;
- int infile_error = 0;
- char initial_outbuf[4096];
- char *outbuf = initial_outbuf;
- size_t outbufsize = sizeof(initial_outbuf);
- int status = 0;
-
-#if O_BINARY
- SET_BINARY(infile);
-#endif
- line = 1; column = 0;
- iconv(cd,NULL,NULL,NULL,NULL);
- for (;;) {
- size_t inbufsize;
- /* Transfer the accumulated output to its destination, in case the
- safe_read() call will block. */
- fflush(stdout);
- inbufsize = safe_read(infile,inbuf+4096,4096);
- if (inbufsize == 0 || inbufsize == SAFE_READ_ERROR) {
- infile_error = (inbufsize == SAFE_READ_ERROR ? errno : 0);
- if (inbufrest == 0)
- break;
- else {
- if (ilseq_byte_subst != NULL)
- subst_mb_to_mb_fallback(inbuf+4096-inbufrest, inbufrest);
- if (!silent)
- conversion_error_EINVAL(infilename);
- status = 1;
- goto done;
- }
- } else {
- const char* inptr = inbuf+4096-inbufrest;
- size_t insize = inbufrest+inbufsize;
- inbufrest = 0;
- while (insize > 0) {
- char* outptr = outbuf;
- size_t outsize = outbufsize;
- size_t res = iconv(cd,(ICONV_CONST char**)&inptr,&insize,&outptr,&outsize);
- if (outptr != outbuf) {
- int saved_errno = errno;
- if (fwrite(outbuf,1,outptr-outbuf,stdout) < outptr-outbuf) {
- status = 1;
- goto done;
- }
- errno = saved_errno;
- }
- if (res == (size_t)(-1)) {
- if (errno == EILSEQ) {
- if (discard_unconvertible == 1) {
- int one = 1;
- iconvctl(cd,ICONV_SET_DISCARD_ILSEQ,&one);
- discard_unconvertible = 2;
- status = 1;
- } else {
- if (!silent)
- conversion_error_EILSEQ(infilename);
- status = 1;
- goto done;
- }
- } else if (errno == EINVAL) {
- if (inbufsize == 0 || insize > 4096) {
- if (!silent)
- conversion_error_EINVAL(infilename);
- status = 1;
- goto done;
- } else {
- inbufrest = insize;
- if (insize > 0) {
- /* Like memcpy(inbuf+4096-insize,inptr,insize), except that
- we cannot use memcpy here, because source and destination
- regions may overlap. */
- char* restptr = inbuf+4096-insize;
- do { *restptr++ = *inptr++; } while (--insize > 0);
- }
- break;
- }
- } else if (errno == E2BIG) {
- if (outptr==outbuf) {
- /* outbuf is too small. Double its size. */
- if (outbuf != initial_outbuf)
- free(outbuf);
- outbufsize = 2*outbufsize;
- if (outbufsize==0) /* integer overflow? */
- xalloc_die();
- outbuf = (char*)xmalloc(outbufsize);
- }
- } else {
- if (!silent)
- conversion_error_other(errno,infilename);
- status = 1;
- goto done;
- }
- }
- }
- }
- }
- for (;;) {
- char* outptr = outbuf;
- size_t outsize = outbufsize;
- size_t res = iconv(cd,NULL,NULL,&outptr,&outsize);
- if (outptr != outbuf) {
- int saved_errno = errno;
- if (fwrite(outbuf,1,outptr-outbuf,stdout) < outptr-outbuf) {
- status = 1;
- goto done;
- }
- errno = saved_errno;
- }
- if (res == (size_t)(-1)) {
- if (errno == EILSEQ) {
- if (discard_unconvertible == 1) {
- int one = 1;
- iconvctl(cd,ICONV_SET_DISCARD_ILSEQ,&one);
- discard_unconvertible = 2;
- status = 1;
- } else {
- if (!silent)
- conversion_error_EILSEQ(infilename);
- status = 1;
- goto done;
- }
- } else if (errno == EINVAL) {
- if (!silent)
- conversion_error_EINVAL(infilename);
- status = 1;
- goto done;
- } else if (errno == E2BIG) {
- if (outptr==outbuf) {
- /* outbuf is too small. Double its size. */
- if (outbuf != initial_outbuf)
- free(outbuf);
- outbufsize = 2*outbufsize;
- if (outbufsize==0) /* integer overflow? */
- xalloc_die();
- outbuf = (char*)xmalloc(outbufsize);
- }
- } else {
- if (!silent)
- conversion_error_other(errno,infilename);
- status = 1;
- goto done;
- }
- } else
- break;
- }
- if (infile_error) {
- fflush(stdout);
- if (column > 0)
- putc('\n',stderr);
- error(0,infile_error,
- /* TRANSLATORS: An error message.
- The placeholder expands to the input file name. */
- _("%s: I/O error"),
- infilename);
- status = 1;
- goto done;
- }
- done:
- if (outbuf != initial_outbuf)
- free(outbuf);
- return status;
-}
-
-/* ========================================================================= */
-
-int main (int argc, char* argv[])
-{
- const char* fromcode = NULL;
- const char* tocode = NULL;
- int do_list = 0;
- iconv_t cd;
- struct iconv_fallbacks fallbacks;
- struct iconv_hooks hooks;
- int i;
- int status;
-
- set_program_name (argv[0]);
-#if HAVE_SETLOCALE
- /* Needed for the locale dependent encodings, "char" and "wchar_t",
- and for gettext. */
- setlocale(LC_CTYPE,"");
-#if ENABLE_NLS
- /* Needed for gettext. */
- setlocale(LC_MESSAGES,"");
-#endif
-#endif
-#if ENABLE_NLS
- bindtextdomain("libiconv",relocate(LOCALEDIR));
-#endif
- textdomain("libiconv");
- for (i = 1; i < argc;) {
- size_t len = strlen(argv[i]);
- if (!strcmp(argv[i],"--")) {
- i++;
- break;
- }
- if (!strcmp(argv[i],"-f")
- /* --f ... --from-code */
- || (len >= 3 && len <= 11 && !strncmp(argv[i],"--from-code",len))
- /* --from-code=... */
- || (len >= 12 && !strncmp(argv[i],"--from-code=",12))) {
- if (len < 12)
- if (i == argc-1) usage(1);
- if (fromcode != NULL) usage(1);
- if (len < 12) {
- fromcode = argv[i+1];
- i += 2;
- } else {
- fromcode = argv[i]+12;
- i++;
- }
- continue;
- }
- if (!strcmp(argv[i],"-t")
- /* --t ... --to-code */
- || (len >= 3 && len <= 9 && !strncmp(argv[i],"--to-code",len))
- /* --from-code=... */
- || (len >= 10 && !strncmp(argv[i],"--to-code=",10))) {
- if (len < 10)
- if (i == argc-1) usage(1);
- if (tocode != NULL) usage(1);
- if (len < 10) {
- tocode = argv[i+1];
- i += 2;
- } else {
- tocode = argv[i]+10;
- i++;
- }
- continue;
- }
- if (!strcmp(argv[i],"-l")
- /* --l ... --list */
- || (len >= 3 && len <= 6 && !strncmp(argv[i],"--list",len))) {
- do_list = 1;
- i++;
- continue;
- }
- if (/* --by ... --byte-subst */
- (len >= 4 && len <= 12 && !strncmp(argv[i],"--byte-subst",len))
- /* --byte-subst=... */
- || (len >= 13 && !strncmp(argv[i],"--byte-subst=",13))) {
- if (len < 13) {
- if (i == argc-1) usage(1);
- ilseq_byte_subst = argv[i+1];
- i += 2;
- } else {
- ilseq_byte_subst = argv[i]+13;
- i++;
- }
- ilseq_byte_subst_size =
- check_subst_formatstring(ilseq_byte_subst, "--byte-subst");
- continue;
- }
- if (/* --w ... --widechar-subst */
- (len >= 3 && len <= 16 && !strncmp(argv[i],"--widechar-subst",len))
- /* --widechar-subst=... */
- || (len >= 17 && !strncmp(argv[i],"--widechar-subst=",17))) {
- if (len < 17) {
- if (i == argc-1) usage(1);
- ilseq_wchar_subst = argv[i+1];
- i += 2;
- } else {
- ilseq_wchar_subst = argv[i]+17;
- i++;
- }
- ilseq_wchar_subst_size =
- check_subst_formatstring(ilseq_wchar_subst, "--widechar-subst");
- continue;
- }
- if (/* --u ... --unicode-subst */
- (len >= 3 && len <= 15 && !strncmp(argv[i],"--unicode-subst",len))
- /* --unicode-subst=... */
- || (len >= 16 && !strncmp(argv[i],"--unicode-subst=",16))) {
- if (len < 16) {
- if (i == argc-1) usage(1);
- ilseq_unicode_subst = argv[i+1];
- i += 2;
- } else {
- ilseq_unicode_subst = argv[i]+16;
- i++;
- }
- ilseq_unicode_subst_size =
- check_subst_formatstring(ilseq_unicode_subst, "--unicode-subst");
- continue;
- }
- if /* --s ... --silent */
- (len >= 3 && len <= 8 && !strncmp(argv[i],"--silent",len)) {
- silent = 1;
- continue;
- }
- if /* --h ... --help */
- (len >= 3 && len <= 6 && !strncmp(argv[i],"--help",len)) {
- usage(0);
- }
- if /* --v ... --version */
- (len >= 3 && len <= 9 && !strncmp(argv[i],"--version",len)) {
- print_version();
- }
-#if O_BINARY
- /* Backward compatibility with iconv <= 1.9.1. */
- if /* --bi ... --binary */
- (len >= 4 && len <= 8 && !strncmp(argv[i],"--binary",len)) {
- i++;
- continue;
- }
-#endif
- if (argv[i][0] == '-') {
- const char *option = argv[i] + 1;
- if (*option == '\0')
- usage(1);
- for (; *option; option++)
- switch (*option) {
- case 'c': discard_unconvertible = 1; break;
- case 's': silent = 1; break;
- default: usage(1);
- }
- i++;
- continue;
- }
- break;
- }
- if (do_list) {
- if (i != 2 || i != argc)
- usage(1);
- iconvlist(print_one,NULL);
- status = 0;
- } else {
-#if O_BINARY
- SET_BINARY(fileno(stdout));
-#endif
- if (fromcode == NULL)
- fromcode = "char";
- if (tocode == NULL)
- tocode = "char";
- cd = iconv_open(tocode,fromcode);
- if (cd == (iconv_t)(-1)) {
- if (iconv_open("UCS-4",fromcode) == (iconv_t)(-1))
- error(0,0,
- /* TRANSLATORS: An error message.
- The placeholder expands to the encoding name, specified through --from-code. */
- _("conversion from %s unsupported"),
- fromcode);
- else if (iconv_open(tocode,"UCS-4") == (iconv_t)(-1))
- error(0,0,
- /* TRANSLATORS: An error message.
- The placeholder expands to the encoding name, specified through --to-code. */
- _("conversion to %s unsupported"),
- tocode);
- else
- error(0,0,
- /* TRANSLATORS: An error message.
- The placeholders expand to the encoding names, specified through --from-code and --to-code, respectively. */
- _("conversion from %s to %s unsupported"),
- fromcode,tocode);
- error(EXIT_FAILURE,0,
- /* TRANSLATORS: Additional advice after an error message.
- The %s placeholder expands to the program name. */
- _("try '%s -l' to get the list of supported encodings"),
- program_name);
- }
- /* Look at fromcode and tocode, to determine whether character widths
- should be determined according to legacy CJK conventions. */
- cjkcode = iconv_canonicalize(tocode);
- if (!is_cjk_encoding(cjkcode))
- cjkcode = iconv_canonicalize(fromcode);
- /* Set up fallback routines for handling impossible conversions. */
- if (ilseq_byte_subst != NULL)
- ilseq_byte_subst_buffer = (char*)xmalloc((ilseq_byte_subst_size+1)*sizeof(char));
- if (!discard_unconvertible) {
- #if HAVE_WCHAR_T
- if (ilseq_wchar_subst != NULL)
- ilseq_wchar_subst_buffer = (char*)xmalloc((ilseq_wchar_subst_size+1)*sizeof(char));
- #endif
- if (ilseq_unicode_subst != NULL)
- ilseq_unicode_subst_buffer = (char*)xmalloc((ilseq_unicode_subst_size+1)*sizeof(char));
- if (ilseq_byte_subst != NULL) {
- subst_mb_to_uc_cd = iconv_open("UCS-4-INTERNAL","char");
- subst_mb_to_uc_temp_buffer = (unsigned int*)xmalloc(ilseq_byte_subst_size*sizeof(unsigned int));
- #if HAVE_WCHAR_T
- subst_mb_to_wc_cd = iconv_open("wchar_t","char");
- subst_mb_to_wc_temp_buffer = (wchar_t*)xmalloc(ilseq_byte_subst_size*sizeof(wchar_t));
- #endif
- subst_mb_to_mb_cd = iconv_open(tocode,"char");
- subst_mb_to_mb_temp_buffer = (char*)xmalloc(ilseq_byte_subst_size*4);
- }
- #if HAVE_WCHAR_T
- if (ilseq_wchar_subst != NULL) {
- subst_wc_to_mb_cd = iconv_open(tocode,"char");
- subst_wc_to_mb_temp_buffer = (char*)xmalloc(ilseq_wchar_subst_size*4);
- }
- #endif
- if (ilseq_unicode_subst != NULL) {
- subst_uc_to_mb_cd = iconv_open(tocode,"char");
- subst_uc_to_mb_temp_buffer = (char*)xmalloc(ilseq_unicode_subst_size*4);
- }
- fallbacks.mb_to_uc_fallback =
- (ilseq_byte_subst != NULL ? subst_mb_to_uc_fallback : NULL);
- fallbacks.uc_to_mb_fallback =
- (ilseq_unicode_subst != NULL ? subst_uc_to_mb_fallback : NULL);
- fallbacks.mb_to_wc_fallback =
- (ilseq_byte_subst != NULL ? subst_mb_to_wc_fallback : NULL);
- fallbacks.wc_to_mb_fallback =
- (ilseq_wchar_subst != NULL ? subst_wc_to_mb_fallback : NULL);
- fallbacks.data = NULL;
- iconvctl(cd, ICONV_SET_FALLBACKS, &fallbacks);
- }
- /* Set up hooks for updating the line and column position. */
- hooks.uc_hook = update_line_column;
- hooks.wc_hook = NULL;
- hooks.data = NULL;
- iconvctl(cd, ICONV_SET_HOOKS, &hooks);
- if (i == argc)
- status = convert(cd,fileno(stdin),
- /* TRANSLATORS: A filename substitute denoting standard input. */
- _("(stdin)"));
- else {
- status = 0;
- for (; i < argc; i++) {
- const char* infilename = argv[i];
- FILE* infile = fopen(infilename,"r");
- if (infile == NULL) {
- int saved_errno = errno;
- error(0,saved_errno,
- /* TRANSLATORS: The first part of an error message.
- It is followed by a colon and a detail message.
- The %s placeholder expands to the input file name. */
- _("%s"),
- infilename);
- status = 1;
- } else {
- status |= convert(cd,fileno(infile),infilename);
- fclose(infile);
- }
- }
- }
- iconv_close(cd);
- }
- if (ferror(stdout) || fclose(stdout)) {
- error(0,0,
- /* TRANSLATORS: An error message. */
- _("I/O error"));
- status = 1;
- }
- exit(status);
-}
diff --git a/deps/libiconv/src/iconv_no_i18n.c b/deps/libiconv/src/iconv_no_i18n.c
deleted file mode 100644
index 88e943b..0000000
--- a/deps/libiconv/src/iconv_no_i18n.c
+++ /dev/null
@@ -1,2 +0,0 @@
-#define NO_I18N
-#include "iconv.c"
diff --git a/lib/iconv.js b/lib/iconv.js
index 2b6cf77..d48dcfb 100644
--- a/lib/iconv.js
+++ b/lib/iconv.js
@@ -14,6 +14,8 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+'use strict';
+
exports.Iconv = Iconv;
var stream = require('stream');
diff --git a/package.json b/package.json
index 2db2abd..f7bb6ba 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "iconv",
"main": "./lib/iconv",
- "version": "2.1.4",
+ "version": "2.1.8",
"description": "Text recoding in JavaScript for fun and profit!",
"homepage": "https://github.com/bnoordhuis/node-iconv",
"repository": {
@@ -18,7 +18,7 @@
"license": "ISC",
"readmeFilename": "README.md",
"dependencies": {
- "nan": "~1.1.1"
+ "nan": "~1.8.0"
},
"devDependencies": {
"tap": "~0.4.8"
diff --git a/src/binding.cc b/src/binding.cc
index e48b2dc..8386d9a 100644
--- a/src/binding.cc
+++ b/src/binding.cc
@@ -37,11 +37,6 @@ using v8::Persistent;
using v8::String;
using v8::Value;
-// TODO(bnoordhuis) Move back into Iconv sometime. Still broken in nan 1.1.1.
-NAN_WEAK_CALLBACK(WeakCallback)
-{
- delete data.GetParameter();
-}
struct Iconv
{
@@ -58,6 +53,12 @@ struct Iconv
iconv_close(conv_);
}
+ NAN_WEAK_CALLBACK(WeakCallback)
+ {
+ delete data.GetParameter();
+ }
+
+
static void Initialize(Handle<Object> obj)
{
NanScope();
@@ -85,7 +86,7 @@ struct Iconv
Iconv* iv = new Iconv(conv);
Local<Object> obj = NanNew<ObjectTemplate>(object_template)->NewInstance();
NanSetInternalFieldPointer(obj, 0, iv);
- NanMakeWeakPersistent(obj, iv, WeakCallback<Object, Iconv>);
+ NanMakeWeakPersistent(obj, iv, &WeakCallback);
NanReturnValue(obj);
}
@@ -118,8 +119,8 @@ struct Iconv
}
input_consumed -= input_size;
output_consumed -= output_size;
- rc->Set(0, NanNew<Integer>(input_consumed));
- rc->Set(1, NanNew<Integer>(output_consumed));
+ rc->Set(0, NanNew<Integer>(static_cast<uint32_t>(input_consumed)));
+ rc->Set(1, NanNew<Integer>(static_cast<uint32_t>(output_consumed)));
NanReturnValue(NanNew<Integer>(errorno));
}
diff --git a/support/config.h b/support/config.h
index bed61c8..56a0a55 100644
--- a/support/config.h
+++ b/support/config.h
@@ -1,3 +1,3 @@
#ifndef locale_charset
-#define locale_charset(s) ("")
+#define locale_charset() ("")
#endif
diff --git a/test/test-basic.js b/test/test-basic.js
index d5320cb..d933e74 100644
--- a/test/test-basic.js
+++ b/test/test-basic.js
@@ -14,6 +14,8 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+'use strict';
+
var assert = require('assert');
var Iconv = require('../lib/iconv').Iconv;
@@ -115,3 +117,14 @@ assert.equal(iconv.convert('ça va が').toString(), 'ca va ');
iconv = Iconv('utf-8', 'iso-8859-1');
assert.equal(iconv.convert('b2s=', 'base64').toString(), 'ok');
+
+var aixEncodings =
+ 'CP856 CP922 CP943 CP1046 CP1124 CP1129 CP1161 CP1162 CP1163';
+
+var dosEncodings =
+ 'CP437 CP737 CP775 CP852 CP853 CP855 CP857 CP858 CP860 CP861 ' +
+ 'CP863 CP864 CP865 CP869 CP1125';
+
+// Check that AIX and DOS encodings are available.
+aixEncodings.split(' ').forEach(function(name) { Iconv(name, 'utf-8'); })
+dosEncodings.split(' ').forEach(function(name) { Iconv(name, 'utf-8'); })
diff --git a/test/test-big-buffer.js b/test/test-big-buffer.js
index d451314..8f8de93 100644
--- a/test/test-big-buffer.js
+++ b/test/test-big-buffer.js
@@ -14,6 +14,8 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+'use strict';
+
var Iconv = require('../lib/iconv').Iconv;
var assert = require('assert');
diff --git a/test/test-stream.js b/test/test-stream.js
index 0eb452d..4009a21 100644
--- a/test/test-stream.js
+++ b/test/test-stream.js
@@ -14,6 +14,8 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+'use strict';
+
var Iconv = require('../lib/iconv').Iconv;
var assert = require('assert');
var stream = require('stream');
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-iconv.git
More information about the Pkg-javascript-commits
mailing list