annotate src/os_macosx.c @ 38:c524f99c7925 v7.0022

updated for version 7.0022
author vimboss
date Sun, 12 Dec 2004 11:37:09 +0000
parents 293621502c4d
children 81c06952fb1d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 /* vi:set ts=8 sts=4 sw=4:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 * VIM - Vi IMproved by Bram Moolenaar
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 * Do ":help uganda" in Vim to read copying and usage conditions.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 * Do ":help credits" in Vim to see a list of people who contributed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 * See README.txt for an overview of the Vim source code.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 * os_macosx.c -- election of os_mac.c or os_unix.c
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 #ifdef MACOS_X_UNIX
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 # ifdef HAVE_CONFIG_H /* Using Makefile. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 # include "vim.h"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 # else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 # include "os_unix.c" /* Using Project Builder */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 # include "os_mac.c"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 # include <TextEncodingConverter.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 #ifdef _DEBUG
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 Trace(char* fmt, ...)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 char buf[2048];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 va_list args;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 va_start(args, fmt);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 /* vsnprintf(buf, sizeof(buf), fmt, args);*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 fprintf(stderr, "%s", buf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 va_end(args);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 #ifdef MACOS_X_ICONVEMU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 * Libiconv emulation layer
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 struct _iconv_t
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 TECObjectRef tec;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 TECObjectRef tecReverse;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 TECSnifferObjectRef sniff;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 TextEncoding from;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 TextEncoding to;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 /* typedef struct _iconv_t *iconv_t; */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 static int last_errno = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 * Get TextEncoding from iconv's encoding name
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 static TextEncoding
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 get_textencoding(const char* encodename)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 static struct {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 const char* name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 TextEncoding encode;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67 } encodetable[] = {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 /* ISO-8859 encodings family */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 {"latin1", kTextEncodingISOLatin1},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 {"latin2", kTextEncodingISOLatin2},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 {"latin3", kTextEncodingISOLatin3},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 {"latin4", kTextEncodingISOLatin4},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 {"latin5", kTextEncodingISOLatin5},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 {"latin6", kTextEncodingISOLatin6},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 {"latin7", kTextEncodingISOLatin7},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 {"latin8", kTextEncodingISOLatin8},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 {"latin9", kTextEncodingISOLatin9},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 {"iso-8859-1", kTextEncodingISOLatin1},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 {"iso-8859-2", kTextEncodingISOLatin2},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 {"iso-8859-3", kTextEncodingISOLatin3},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 {"iso-8859-4", kTextEncodingISOLatin4},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 {"iso-8859-5", kTextEncodingISOLatinCyrillic},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 {"iso-8859-6", kTextEncodingISOLatinArabic},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84 {"iso-8859-7", kTextEncodingISOLatinGreek},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85 {"iso-8859-8", kTextEncodingISOLatinHebrew},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 {"iso-8859-9", kTextEncodingISOLatin5},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 {"iso-8859-10", kTextEncodingISOLatin6},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89 /* Unicode encodings. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90 /* TODO: Add other type of unicode */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91 {"ucs-2", kTextEncodingMacUnicode},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93 /* Japanese encoding aliases */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94 {"cp932", kTextEncodingShiftJIS},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95 {"shift-jis", kTextEncodingShiftJIS},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96 {"euc-jp", kTextEncodingEUC_JP},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97 {"iso-2022-jp", kTextEncodingISO_2022_JP},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98 {"iso-2022-jp-1", kTextEncodingISO_2022_JP_1},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99 {"iso-2022-jp-2", kTextEncodingISO_2022_JP_2},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100 {"iso-2022-jp-3", kTextEncodingISO_2022_JP_3},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102 /* Other aliases. These aliases in this block are just guessed. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103 /* TODO: Must be verified. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104 {"gb2312", kTextEncodingGB_2312_80},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105 {"cp936", kTextEncodingMacChineseSimp},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106 {"euc-cn", kTextEncodingEUC_CN},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107 {"cp950", kTextEncodingMacChineseTrad},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108 {"euc-tw", kTextEncodingEUC_TW},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109 {"cp949", kTextEncodingMacKorean},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110 {"euc-kr", kTextEncodingEUC_KR},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
111
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
113 * All encodings supported by Macintosh. You can find these values
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
114 * in a file:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115 * /System/Library/Frameworks/CoreServices.framework/Versions/A/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116 * Frameworks/CarbonCore.framework/Versions/A/Headers/TextCommon.h
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118 {"MacRoman", kTextEncodingMacRoman},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119 {"MacJapanese", kTextEncodingMacJapanese},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120 {"MacChineseTrad", kTextEncodingMacChineseTrad},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121 {"MacKorean", kTextEncodingMacKorean},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122 {"MacArabic", kTextEncodingMacArabic},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123 {"MacHebrew", kTextEncodingMacHebrew},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124 {"MacGreek", kTextEncodingMacGreek},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
125 {"MacCyrillic", kTextEncodingMacCyrillic},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
126 {"MacDevanagari", kTextEncodingMacDevanagari},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
127 {"MacGurmukhi", kTextEncodingMacGurmukhi},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128 {"MacGujarati", kTextEncodingMacGujarati},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
129 {"MacOriya", kTextEncodingMacOriya},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
130 {"MacBengali", kTextEncodingMacBengali},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
131 {"MacTamil", kTextEncodingMacTamil},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
132 {"MacTelugu", kTextEncodingMacTelugu},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
133 {"MacKannada", kTextEncodingMacKannada},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134 {"MacMalayalam", kTextEncodingMacMalayalam},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
135 {"MacSinhalese", kTextEncodingMacSinhalese},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
136 {"MacBurmese", kTextEncodingMacBurmese},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
137 {"MacKhmer", kTextEncodingMacKhmer},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
138 {"MacThai", kTextEncodingMacThai},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
139 {"MacLaotian", kTextEncodingMacLaotian},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
140 {"MacGeorgian", kTextEncodingMacGeorgian},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
141 {"MacArmenian", kTextEncodingMacArmenian},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
142 {"MacChineseSimp", kTextEncodingMacChineseSimp},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
143 {"MacTibetan", kTextEncodingMacTibetan},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
144 {"MacMongolian", kTextEncodingMacMongolian},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
145 {"MacEthiopic", kTextEncodingMacEthiopic},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
146 {"MacCentralEurRoman", kTextEncodingMacCentralEurRoman},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
147 {"MacVietnamese", kTextEncodingMacVietnamese},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
148 {"MacExtArabic", kTextEncodingMacExtArabic},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
149 {"MacSymbol", kTextEncodingMacSymbol},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
150 {"MacDingbats", kTextEncodingMacDingbats},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
151 {"MacTurkish", kTextEncodingMacTurkish},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
152 {"MacCroatian", kTextEncodingMacCroatian},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
153 {"MacIcelandic", kTextEncodingMacIcelandic},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
154 {"MacRomanian", kTextEncodingMacRomanian},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
155 {"MacCeltic", kTextEncodingMacCeltic},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
156 {"MacGaelic", kTextEncodingMacGaelic},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
157 {"MacKeyboardGlyphs", kTextEncodingMacKeyboardGlyphs},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
158 {"MacTradChinese", kTextEncodingMacTradChinese},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
159 {"MacRSymbol", kTextEncodingMacRSymbol},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
160 {"MacSimpChinese", kTextEncodingMacSimpChinese},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
161 {"MacGeez", kTextEncodingMacGeez},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
162 {"MacEastEurRoman", kTextEncodingMacEastEurRoman},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
163 {"MacUninterp", kTextEncodingMacUninterp},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
164 {"MacUnicode", kTextEncodingMacUnicode},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
165 {"MacFarsi", kTextEncodingMacFarsi},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
166 {"MacUkrainian", kTextEncodingMacUkrainian},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
167 {"MacInuit", kTextEncodingMacInuit},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
168 {"MacVT100", kTextEncodingMacVT100},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
169 {"MacHFS", kTextEncodingMacHFS},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
170 {"UnicodeDefault", kTextEncodingUnicodeDefault},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
171 {"UnicodeV1_1", kTextEncodingUnicodeV1_1},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
172 {"ISO10646_1993", kTextEncodingISO10646_1993},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
173 {"UnicodeV2_0", kTextEncodingUnicodeV2_0},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
174 {"UnicodeV2_1", kTextEncodingUnicodeV2_1},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
175 {"UnicodeV3_0", kTextEncodingUnicodeV3_0},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
176 {"UnicodeV3_1", kTextEncodingUnicodeV3_1},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
177 {"UnicodeV3_2", kTextEncodingUnicodeV3_2},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
178 {"ISOLatin1", kTextEncodingISOLatin1},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
179 {"ISOLatin2", kTextEncodingISOLatin2},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
180 {"ISOLatin3", kTextEncodingISOLatin3},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
181 {"ISOLatin4", kTextEncodingISOLatin4},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
182 {"ISOLatinCyrillic", kTextEncodingISOLatinCyrillic},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
183 {"ISOLatinArabic", kTextEncodingISOLatinArabic},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
184 {"ISOLatinGreek", kTextEncodingISOLatinGreek},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
185 {"ISOLatinHebrew", kTextEncodingISOLatinHebrew},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
186 {"ISOLatin5", kTextEncodingISOLatin5},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
187 {"ISOLatin6", kTextEncodingISOLatin6},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
188 {"ISOLatin7", kTextEncodingISOLatin7},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
189 {"ISOLatin8", kTextEncodingISOLatin8},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
190 {"ISOLatin9", kTextEncodingISOLatin9},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
191 {"DOSLatinUS", kTextEncodingDOSLatinUS},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
192 {"DOSGreek", kTextEncodingDOSGreek},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
193 {"DOSBalticRim", kTextEncodingDOSBalticRim},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
194 {"DOSLatin1", kTextEncodingDOSLatin1},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
195 {"DOSGreek1", kTextEncodingDOSGreek1},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
196 {"DOSLatin2", kTextEncodingDOSLatin2},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
197 {"DOSCyrillic", kTextEncodingDOSCyrillic},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
198 {"DOSTurkish", kTextEncodingDOSTurkish},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
199 {"DOSPortuguese", kTextEncodingDOSPortuguese},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
200 {"DOSIcelandic", kTextEncodingDOSIcelandic},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
201 {"DOSHebrew", kTextEncodingDOSHebrew},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
202 {"DOSCanadianFrench", kTextEncodingDOSCanadianFrench},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
203 {"DOSArabic", kTextEncodingDOSArabic},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
204 {"DOSNordic", kTextEncodingDOSNordic},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
205 {"DOSRussian", kTextEncodingDOSRussian},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
206 {"DOSGreek2", kTextEncodingDOSGreek2},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
207 {"DOSThai", kTextEncodingDOSThai},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
208 {"DOSJapanese", kTextEncodingDOSJapanese},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
209 {"DOSChineseSimplif", kTextEncodingDOSChineseSimplif},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
210 {"DOSKorean", kTextEncodingDOSKorean},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
211 {"DOSChineseTrad", kTextEncodingDOSChineseTrad},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
212 {"WindowsLatin1", kTextEncodingWindowsLatin1},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
213 {"WindowsANSI", kTextEncodingWindowsANSI},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
214 {"WindowsLatin2", kTextEncodingWindowsLatin2},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
215 {"WindowsCyrillic", kTextEncodingWindowsCyrillic},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
216 {"WindowsGreek", kTextEncodingWindowsGreek},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
217 {"WindowsLatin5", kTextEncodingWindowsLatin5},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
218 {"WindowsHebrew", kTextEncodingWindowsHebrew},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
219 {"WindowsArabic", kTextEncodingWindowsArabic},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
220 {"WindowsBalticRim", kTextEncodingWindowsBalticRim},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
221 {"WindowsVietnamese", kTextEncodingWindowsVietnamese},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
222 {"WindowsKoreanJohab", kTextEncodingWindowsKoreanJohab},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
223 {"US_ASCII", kTextEncodingUS_ASCII},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
224 {"JIS_X0201_76", kTextEncodingJIS_X0201_76},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
225 {"JIS_X0208_83", kTextEncodingJIS_X0208_83},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
226 {"JIS_X0208_90", kTextEncodingJIS_X0208_90},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
227 {"JIS_X0212_90", kTextEncodingJIS_X0212_90},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
228 {"JIS_C6226_78", kTextEncodingJIS_C6226_78},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
229 {"ShiftJIS_X0213_00", kTextEncodingShiftJIS_X0213_00},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
230 {"GB_2312_80", kTextEncodingGB_2312_80},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
231 {"GBK_95", kTextEncodingGBK_95},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
232 {"GB_18030_2000", kTextEncodingGB_18030_2000},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
233 {"KSC_5601_87", kTextEncodingKSC_5601_87},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
234 {"KSC_5601_92_Johab", kTextEncodingKSC_5601_92_Johab},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
235 {"CNS_11643_92_P1", kTextEncodingCNS_11643_92_P1},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
236 {"CNS_11643_92_P2", kTextEncodingCNS_11643_92_P2},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
237 {"CNS_11643_92_P3", kTextEncodingCNS_11643_92_P3},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
238 {"ISO_2022_JP", kTextEncodingISO_2022_JP},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
239 {"ISO_2022_JP_2", kTextEncodingISO_2022_JP_2},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
240 {"ISO_2022_JP_1", kTextEncodingISO_2022_JP_1},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
241 {"ISO_2022_JP_3", kTextEncodingISO_2022_JP_3},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
242 {"ISO_2022_CN", kTextEncodingISO_2022_CN},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
243 {"ISO_2022_CN_EXT", kTextEncodingISO_2022_CN_EXT},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
244 {"ISO_2022_KR", kTextEncodingISO_2022_KR},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
245 {"EUC_JP", kTextEncodingEUC_JP},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
246 {"EUC_CN", kTextEncodingEUC_CN},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
247 {"EUC_TW", kTextEncodingEUC_TW},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
248 {"EUC_KR", kTextEncodingEUC_KR},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
249 {"ShiftJIS", kTextEncodingShiftJIS},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
250 {"KOI8_R", kTextEncodingKOI8_R},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
251 {"Big5", kTextEncodingBig5},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
252 {"MacRomanLatin1", kTextEncodingMacRomanLatin1},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
253 {"HZ_GB_2312", kTextEncodingHZ_GB_2312},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
254 {"Big5_HKSCS_1999", kTextEncodingBig5_HKSCS_1999},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
255 {"NextStepLatin", kTextEncodingNextStepLatin},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
256 {"EBCDIC_US", kTextEncodingEBCDIC_US},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
257 {"EBCDIC_CP037", kTextEncodingEBCDIC_CP037},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
258 {"MultiRun", kTextEncodingMultiRun},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
259
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
260 /* Terminator */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
261 {NULL, -1},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
262 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
263 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
264
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
265 i = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
266 for (i = 0; encodetable[i].name != NULL; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
267 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
268 if (STRICMP(encodename, encodetable[i].name) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
269 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
270 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
271 return encodetable[i].encode;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
272 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
273
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
274 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
275 * iconv interfaces
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
276 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
277
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
278 iconv_t
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
279 iconv_open(const char* tocode, const char* fromcode)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
280 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
281 TextEncoding toEnc, fromEnc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
282 iconv_t cd = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
283 OSStatus st;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
284
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
285 /* Verify to/from encoding name */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
286 toEnc = get_textencoding(tocode);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
287 fromEnc = get_textencoding(fromcode);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
288 if (toEnc < 0 || fromEnc < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
289 goto ICONV_OPEN_ERR;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
290
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
291 /* Allocate memory to object */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
292 cd = (iconv_t)alloc(sizeof(struct _iconv_t));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
293 if (!cd)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
294 goto ICONV_OPEN_ERR;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
295 memset(cd, 0, sizeof(struct _iconv_t));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
296
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
297 /* Create converter */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
298 if (fromEnc != toEnc)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
299 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
300 TRACE("*** fromEnc=%d toEnc=%d\n", (int)fromEnc, (int)toEnc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
301 st = TECCreateConverter(&cd->tec, fromEnc, toEnc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
302 if (st != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
303 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
304 TRACE("*** TECCreateConverter()=%d\n", (int)st);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
305 goto ICONV_OPEN_ERR;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
306 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
307 /* Create reverse converter */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
308 st = TECCreateConverter(&cd->tecReverse, toEnc, fromEnc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
309 if (st != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
310 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
311 TRACE("*** TECCreateConverter()=%d (reverse)\n", (int)st);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
312 goto ICONV_OPEN_ERR;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
313 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
314 /* Create Sniffer */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
315 st = TECCreateSniffer(&cd->sniff, &fromEnc, 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
316 if (st != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
317 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
318 TRACE("*** TECCreateSniffer()=%d\n", (int)st);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
319 goto ICONV_OPEN_ERR;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
320 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
321 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
322
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
323 cd->from = fromEnc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
324 cd->to = toEnc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
325 last_errno = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
326 return cd;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
327
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
328 ICONV_OPEN_ERR:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
329 if (cd)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
330 iconv_close(cd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
331 last_errno = EINVAL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
332 return (iconv_t)-1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
333 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
334
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
335 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
336 * Used when there are same value in 'from encoding' and 'to encoding'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
337 * TEC doesn't support conversion between same encodings, and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
338 * TECCreateConverter() failed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
339 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
340 static size_t
18
293621502c4d updated for version 7.0010
vimboss
parents: 7
diff changeset
341 null_conv(iconv_t cd, const char **inbuf, size_t *inbytesleft,
293621502c4d updated for version 7.0010
vimboss
parents: 7
diff changeset
342 char **outbuf, size_t *outbytesleft)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
343 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
344 const char* buf_in = inbuf && *inbuf ? *inbuf : NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
345 char* buf_out = outbuf && *outbuf ? *outbuf : NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
346
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
347 if (buf_in)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
348 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
349 int in_len = inbytesleft ? *inbytesleft : 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
350 int out_len = outbytesleft ? *outbytesleft : 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
351
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
352 if (!buf_out || out_len <= 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
353 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
354 last_errno = E2BIG;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
355 return -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
356 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
357 else if (in_len > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
358 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
359 int len = in_len < out_len ? in_len : out_len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
360
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
361 memcpy (buf_out, buf_in, len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
362 *inbuf += len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
363 *outbuf += len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
364 *inbytesleft -= len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
365 *outbytesleft -= len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
366 if (*outbytesleft <= 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
367 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
368 last_errno = E2BIG;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
369 return -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
370 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
371 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
372 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
373 last_errno = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
374 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
375 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
376
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
377 size_t
18
293621502c4d updated for version 7.0010
vimboss
parents: 7
diff changeset
378 iconv(iconv_t cd, const char **inbuf, size_t *inbytesleft,
293621502c4d updated for version 7.0010
vimboss
parents: 7
diff changeset
379 char **outbuf, size_t *outbytesleft)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
380 {
18
293621502c4d updated for version 7.0010
vimboss
parents: 7
diff changeset
381 ConstTextPtr buf_in;
293621502c4d updated for version 7.0010
vimboss
parents: 7
diff changeset
382 TextPtr buf_out;
293621502c4d updated for version 7.0010
vimboss
parents: 7
diff changeset
383 ByteCount out_len, out_true;
293621502c4d updated for version 7.0010
vimboss
parents: 7
diff changeset
384 ByteCount in_len, in_true;
293621502c4d updated for version 7.0010
vimboss
parents: 7
diff changeset
385 OSStatus st;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
386
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
387 if (!cd)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
388 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
389 last_errno = ENOENT; /* TODO: Another error code should be set */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
390 return -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
391 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
392 if (cd->from == cd->to)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
393 return null_conv(cd, inbuf, inbytesleft, outbuf, outbytesleft) ;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
394
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
395 buf_in = (TextPtr) inbuf ;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
396 buf_out = (TextPtr) outbuf ;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
397 out_len = out_true = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
398 in_len = in_true = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
399
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
400 if (buf_in && buf_out)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
401 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
402 ItemCount error, feature;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
403
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
404 /* Normal convert mode */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
405 if (!inbytesleft || !outbytesleft)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
406 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
407 last_errno = EFAULT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
408 return -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
409 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
410 in_len = *inbytesleft;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
411 out_len = *outbytesleft;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
412
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
413 /* Check stream is form in expected encoding or not */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
414 st = TECSniffTextEncoding(cd->sniff, (TextPtr)buf_in, in_len,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
415 &cd->from, 1, &error, 1, &feature, 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
416 TRACE("TECSniffTextEncoding()=%d error=%d feature=%d\n",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
417 (int)st, (int)error, (int)feature);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
418 if ((error != 0 || feature == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
419 && !(error == 0xffffffff && feature == 0xffffffff))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
420 /* Not expected encoding */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
421 st = kTECUnmappableElementErr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
422 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
423 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
424 /* Do convert */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
425 st = TECConvertText(cd->tec,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
426 buf_in, in_len, &in_true,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
427 buf_out, out_len, &out_true);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
428 /* Verify converted text. Compare original text with reverse
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
429 * converted text. If not match, there is some problem on
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
430 * converting. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
431 if (st == 0 && in_true > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
432 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
433 ByteCount rev_in, rev_out;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
434 TextPtr buf_rev = (TextPtr)alloc(in_true);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
435
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
436 if (buf_rev)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
437 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
438 st = TECConvertText(cd->tecReverse,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
439 buf_out, out_true, &rev_in,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
440 buf_rev, in_true, &rev_out);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
441 if (st != 0 || rev_in != out_true || rev_out != in_true
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
442 || memcmp(buf_rev, buf_in, rev_out) != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
443 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
444 #ifdef ICONVOSX_DEBUG
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
445 fprintf(stderr, " reverse conversion failed.\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
446 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
447 st = kTECUnmappableElementErr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
448 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
449 vim_free(buf_rev);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
450 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
451 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
452 st = kTECUnmappableElementErr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
453 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
454 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
455 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
456 else if (!buf_in && buf_out)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
457 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
458 /* Flush all buffered strings to buffer, and reset status */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
459 if (!outbytesleft)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
460 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
461 last_errno = EFAULT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
462 return -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
463 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
464 out_len = *outbytesleft;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
465 st = TECFlushText(cd->tec,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
466 buf_out, out_len, &out_true);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
467 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
468 else if (!buf_in && !buf_out)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
469 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
470 /* Reset cd's status and cancel buffered strings */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
471 unsigned char tmp_out[256];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
472
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
473 buf_out = tmp_out;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
474 out_len = sizeof(tmp_out);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
475 st = TECFlushText(cd->tec,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
476 buf_out, out_len, &out_true);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
477 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
478 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
479 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
480 last_errno = EFAULT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
481 return -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
482 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
483 TRACE("st=%d, buf_in=%p, in_len=%d, in_true=%d\n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
484 " buf_out=%p, out_len=%d, out_true=%d\n", (int)st,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
485 buf_in, (int)in_len, (int)in_true,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
486 buf_out, (int)out_len, (int)out_true);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
487
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
488 switch (st)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
489 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
490 case 0:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
491 /* No error */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
492 if (inbytesleft)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
493 *inbytesleft -= in_true;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
494 if (outbytesleft)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
495 *outbytesleft -= out_true;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
496 if (inbuf && *inbuf)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
497 *inbuf += in_true;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
498 if (outbuf && *outbuf)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
499 *outbuf += out_true;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
500 last_errno = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
501 return 0; /* No error */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
502 case kTECUnmappableElementErr:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
503 last_errno = EILSEQ;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
504 case kTECIncompleteElementErr:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
505 last_errno = EINVAL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
506 case kTECOutputBufferFullStatus:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
507 last_errno = E2BIG;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
508 return -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
509 default:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
510 TRACE("iconv(%p, %p, %p, %p, %p) failed. (%d)\n",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
511 cd, inbuf, inbytesleft, outbuf, outbytesleft, (int)st);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
512 last_errno = EFAULT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
513 return -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
514 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
515 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
516
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
517 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
518 iconv_close(iconv_t cd)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
519 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
520 if (cd)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
521 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
522 /* Free all elements of iconv_t */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
523 if (cd->tec)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
524 TECDisposeConverter(cd->tec);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
525 if (cd->tecReverse)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
526 TECDisposeConverter(cd->tecReverse);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
527 if (cd->sniff)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
528 TECDisposeSniffer(cd->sniff);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
529 vim_free(cd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
530 last_errno = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
531 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
532 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
533 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
534 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
535 last_errno = EINVAL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
536 return -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
537 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
538 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
539
18
293621502c4d updated for version 7.0010
vimboss
parents: 7
diff changeset
540 int *
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
541 iconv_errno()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
542 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
543 return &last_errno;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
544 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
545 #endif /* MACOS_X_ICONVEMU */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
546
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
547 #ifdef USE_MCH_GETTEXT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
548
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
549 #define GETTEXT_BUFNUM 64
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
550 #define GETTEXT_BUFSIZE 256
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
551
18
293621502c4d updated for version 7.0010
vimboss
parents: 7
diff changeset
552 char *
293621502c4d updated for version 7.0010
vimboss
parents: 7
diff changeset
553 mch_gettext(const char *msgid)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
554 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
555 static char buf[GETTEXT_BUFNUM][GETTEXT_BUFSIZE];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
556 static int bufnum = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
557 const char *msg = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
558 CFStringRef strkey = NULL, strmsg = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
559 CFStringEncoding enc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
560
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
561 if (!msgid)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
562 goto MCH_GETTEXT_FINISH;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
563 enc = CFStringGetSystemEncoding();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
564 TRACE("mch_gettext(%s)\n", msgid);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
565
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
566 strkey = CFStringCreateWithCString(NULL, msgid, enc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
567 if (!strkey)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
568 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
569 TRACE(" Can't create a CFString for msgid.\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
570 goto MCH_GETTEXT_FINISH;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
571 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
572
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
573 strmsg = CFCopyLocalizedString(strkey, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
574 if (!strmsg)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
575 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
576 TRACE(" No localized strings for msgid.\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
577 goto MCH_GETTEXT_FINISH;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
578 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
579
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
580 msg = CFStringGetCStringPtr(strmsg, enc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
581 if (!msg)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
582 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
583 /* This is as backup when CFStringGetCStringPtr was failed */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
584 CFStringGetCString(strmsg, buf[bufnum], GETTEXT_BUFSIZE, enc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
585 msg = buf[bufnum];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
586 if (++bufnum >= GETTEXT_BUFNUM)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
587 bufnum = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
588 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
589 TRACE(" Localized to: %s\n", msg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
590
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
591 MCH_GETTEXT_FINISH:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
592 if (strkey)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
593 CFRelease(strkey);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
594 if (strmsg)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
595 CFRelease(strmsg);
18
293621502c4d updated for version 7.0010
vimboss
parents: 7
diff changeset
596 return (char *)(msg ? msg : msgid);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
597 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
598
18
293621502c4d updated for version 7.0010
vimboss
parents: 7
diff changeset
599 char *
293621502c4d updated for version 7.0010
vimboss
parents: 7
diff changeset
600 mch_bindtextdomain(const char *domain, const char *dirname)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
601 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
602 TRACE("mch_bindtextdomain(%s, %s)\n", domain, dirname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
603 return (char*)dirname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
604 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
605
18
293621502c4d updated for version 7.0010
vimboss
parents: 7
diff changeset
606 char *
293621502c4d updated for version 7.0010
vimboss
parents: 7
diff changeset
607 mch_textdomain(const char *domain)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
608 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
609 TRACE("mch_textdomain(%s)\n", domain);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
610 return (char*)domain;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
611 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
612 #endif