Revisión | bb574c0a72ae6108d95c86e2e68405df467ad7f9 (tree) |
---|---|
Tiempo | 2016-10-05 23:27:35 |
Autor | Koji Arai <jca02266@gmai...> |
Commiter | Koji Arai |
Prefer to use the iconv on MacOS X
Thanks to hirotosakai
@@ -1907,7 +1907,7 @@ write_header(fp, hdr) | ||
1907 | 1907 | |
1908 | 1908 | #if MULTIBYTE_FILENAME |
1909 | 1909 | |
1910 | -#if defined(__APPLE__) /* Added by Hiroto Sakai */ | |
1910 | +#if defined(__APPLE__) && !defined(HAVE_ICONV) /* Added by Hiroto Sakai */ | |
1911 | 1911 | |
1912 | 1912 | #include <CoreFoundation/CFString.h> |
1913 | 1913 | #include <CoreFoundation/CFStringEncodingExt.h> |
@@ -2045,11 +2045,16 @@ char * | ||
2045 | 2045 | sjis_to_utf8(char *dst, const char *src, size_t dstsize) |
2046 | 2046 | { |
2047 | 2047 | #if defined(__APPLE__) |
2048 | +#if !defined(HAVE_ICONV) | |
2048 | 2049 | dst[0] = '\0'; |
2049 | 2050 | if (ConvertEncodingToUTF8(src, dst, dstsize, |
2050 | 2051 | kCFStringEncodingDOSJapanese, |
2051 | 2052 | kCFStringEncodingUseHFSPlusCanonical) == 0) |
2052 | 2053 | return dst; |
2054 | +#else | |
2055 | + if (ConvertEncodingByIconv(src, dst, dstsize, "SJIS", "UTF-8-MAC") != -1) | |
2056 | + return dst; | |
2057 | +#endif | |
2053 | 2058 | #elif HAVE_ICONV |
2054 | 2059 | if (ConvertEncodingByIconv(src, dst, dstsize, "SJIS", "UTF-8") != -1) |
2055 | 2060 | return dst; |
@@ -2066,6 +2071,7 @@ char * | ||
2066 | 2071 | utf8_to_sjis(char *dst, const char *src, size_t dstsize) |
2067 | 2072 | { |
2068 | 2073 | #if defined(__APPLE__) |
2074 | +#if !defined(HAVE_ICONV) | |
2069 | 2075 | int srclen; |
2070 | 2076 | |
2071 | 2077 | dst[0] = '\0'; |
@@ -2074,6 +2080,10 @@ utf8_to_sjis(char *dst, const char *src, size_t dstsize) | ||
2074 | 2080 | kCFStringEncodingDOSJapanese, |
2075 | 2081 | kCFStringEncodingUseHFSPlusCanonical) == 0) |
2076 | 2082 | return dst; |
2083 | +#else | |
2084 | + if (ConvertEncodingByIconv(src, dst, dstsize, "UTF-8-MAC", "SJIS") != -1) | |
2085 | + return dst; | |
2086 | +#endif | |
2077 | 2087 | #elif HAVE_ICONV |
2078 | 2088 | if (ConvertEncodingByIconv(src, dst, dstsize, "UTF-8", "SJIS") != -1) |
2079 | 2089 | return dst; |