annotate src/os_mac_conv.c @ 7933:1f0743f4f88f v7.4.1262

commit https://github.com/vim/vim/commit/a07fec9c85d062acd9dd433a2e681770f459ba47 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Feb 5 21:04:08 2016 +0100 patch 7.4.1262 Problem: The channel callback is not invoked. Solution: Make a list of pending callbacks.
author Christian Brabandt <cb@256bit.org>
date Fri, 05 Feb 2016 21:15:04 +0100
parents c079097365f3
children 068f397d0da4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
1 /* vi:set ts=8 sts=4 sw=4:
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
2 *
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
3 * VIM - Vi IMproved by Bram Moolenaar
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
4 *
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
5 * Do ":help uganda" in Vim to read copying and usage conditions.
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
6 * Do ":help credits" in Vim to see a list of people who contributed.
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
7 * See README.txt for an overview of the Vim source code.
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
8 */
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
9 /*
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
10 * os_mac_conv.c: Code specifically for Mac string conversions.
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
11 *
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
12 * This code has been put in a separate file to avoid the conflicts that are
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
13 * caused by including both the X11 and Carbon header files.
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
14 */
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
15
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
16 #define NO_X11_INCLUDES
2891
acda456c788a updated for version 7.3.219
Bram Moolenaar <bram@vim.org>
parents: 2309
diff changeset
17 #define BalloonEval int /* used in header files */
acda456c788a updated for version 7.3.219
Bram Moolenaar <bram@vim.org>
parents: 2309
diff changeset
18
18
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
19 #include "vim.h"
7811
7fda54504fee commit https://github.com/vim/vim/commit/3e96c3d241ab657cf4df0913ea8de50a6cb90730
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
20
7fda54504fee commit https://github.com/vim/vim/commit/3e96c3d241ab657cf4df0913ea8de50a6cb90730
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
21 #if !defined(FEAT_GUI_MAC) && !defined(PROTO)
2309
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 1621
diff changeset
22 # include <CoreServices/CoreServices.h>
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 1621
diff changeset
23 #endif
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 1621
diff changeset
24
18
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
25
766
f0d0d3d3a1e2 updated for version 7.0225
vimboss
parents: 501
diff changeset
26 #if defined(MACOS_CONVERT) || defined(PROTO)
2309
543ea69d037f Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents: 1621
diff changeset
27
766
f0d0d3d3a1e2 updated for version 7.0225
vimboss
parents: 501
diff changeset
28 # ifdef PROTO
f0d0d3d3a1e2 updated for version 7.0225
vimboss
parents: 501
diff changeset
29 /* A few dummy types to be able to generate function prototypes. */
f0d0d3d3a1e2 updated for version 7.0225
vimboss
parents: 501
diff changeset
30 typedef int UniChar;
f0d0d3d3a1e2 updated for version 7.0225
vimboss
parents: 501
diff changeset
31 typedef int *TECObjectRef;
f0d0d3d3a1e2 updated for version 7.0225
vimboss
parents: 501
diff changeset
32 typedef int CFStringRef;
f0d0d3d3a1e2 updated for version 7.0225
vimboss
parents: 501
diff changeset
33 # endif
f0d0d3d3a1e2 updated for version 7.0225
vimboss
parents: 501
diff changeset
34
7805
0b6c37dd858d commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents: 3143
diff changeset
35 static char_u *mac_utf16_to_utf8(UniChar *from, size_t fromLen, size_t *actualLen);
0b6c37dd858d commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents: 3143
diff changeset
36 static UniChar *mac_utf8_to_utf16(char_u *from, size_t fromLen, size_t *actualLen);
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
37
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
38 /* Converter for composing decomposed HFS+ file paths */
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
39 static TECObjectRef gPathConverter;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
40 /* Converter used by mac_utf16_to_utf8 */
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
41 static TECObjectRef gUTF16ToUTF8Converter;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
42
18
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
43 /*
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
44 * A Mac version of string_convert_ext() for special cases.
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
45 */
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
46 char_u *
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7811
diff changeset
47 mac_string_convert(
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7811
diff changeset
48 char_u *ptr,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7811
diff changeset
49 int len,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7811
diff changeset
50 int *lenp,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7811
diff changeset
51 int fail_on_error,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7811
diff changeset
52 int from_enc,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7811
diff changeset
53 int to_enc,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7811
diff changeset
54 int *unconvlenp)
18
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
55 {
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
56 char_u *retval, *d;
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
57 CFStringRef cfstr;
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
58 int buflen, in, out, l, i;
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
59 CFStringEncoding from;
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
60 CFStringEncoding to;
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
61
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
62 switch (from_enc)
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
63 {
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
64 case 'l': from = kCFStringEncodingISOLatin1; break;
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
65 case 'm': from = kCFStringEncodingMacRoman; break;
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
66 case 'u': from = kCFStringEncodingUTF8; break;
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
67 default: return NULL;
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
68 }
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
69 switch (to_enc)
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
70 {
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
71 case 'l': to = kCFStringEncodingISOLatin1; break;
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
72 case 'm': to = kCFStringEncodingMacRoman; break;
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
73 case 'u': to = kCFStringEncodingUTF8; break;
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
74 default: return NULL;
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
75 }
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
76
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
77 if (unconvlenp != NULL)
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
78 *unconvlenp = 0;
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
79 cfstr = CFStringCreateWithBytes(NULL, ptr, len, from, 0);
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
80
3143
314d9368069e updated for version 7.3.342
Bram Moolenaar <bram@vim.org>
parents: 2891
diff changeset
81 if (cfstr == NULL)
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
82 fprintf(stderr, "Encoding failed\n");
18
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
83 /* When conversion failed, try excluding bytes from the end, helps when
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
84 * there is an incomplete byte sequence. Only do up to 6 bytes to avoid
1212
e085b0f7b036 updated for version 7.1b
vimboss
parents: 766
diff changeset
85 * looping a long time when there really is something unconvertible. */
18
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
86 while (cfstr == NULL && unconvlenp != NULL && len > 1 && *unconvlenp < 6)
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
87 {
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
88 --len;
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
89 ++*unconvlenp;
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
90 cfstr = CFStringCreateWithBytes(NULL, ptr, len, from, 0);
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
91 }
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
92 if (cfstr == NULL)
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
93 return NULL;
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
94
18
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
95 if (to == kCFStringEncodingUTF8)
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
96 buflen = len * 6 + 1;
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
97 else
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
98 buflen = len + 1;
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
99 retval = alloc(buflen);
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
100 if (retval == NULL)
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
101 {
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
102 CFRelease(cfstr);
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
103 return NULL;
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
104 }
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
105
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
106 #if 0
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
107 CFRange convertRange = CFRangeMake(0, CFStringGetLength(cfstr));
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
108 /* Determine output buffer size */
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
109 CFStringGetBytes(cfstr, convertRange, to, NULL, FALSE, NULL, 0, (CFIndex *)&buflen);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
110 retval = (buflen > 0) ? alloc(buflen) : NULL;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
111 if (retval == NULL) {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
112 CFRelease(cfstr);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
113 return NULL;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
114 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
115
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
116 if (lenp)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
117 *lenp = buflen / sizeof(char_u);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
118
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
119 if (!CFStringGetBytes(cfstr, convertRange, to, NULL, FALSE, retval, buflen, NULL))
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
120 #endif
501
ce2181d14aa0 updated for version 7.0139
vimboss
parents: 474
diff changeset
121 if (!CFStringGetCString(cfstr, (char *)retval, buflen, to))
18
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
122 {
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
123 CFRelease(cfstr);
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
124 if (fail_on_error)
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
125 {
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
126 vim_free(retval);
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
127 return NULL;
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
128 }
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
129
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
130 fprintf(stderr, "Trying char-by-char conversion...\n");
18
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
131 /* conversion failed for the whole string, but maybe it will work
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
132 * for each character */
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
133 for (d = retval, in = 0, out = 0; in < len && out < buflen - 1;)
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
134 {
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
135 if (from == kCFStringEncodingUTF8)
474
a5fcf36ef512 updated for version 7.0127
vimboss
parents: 179
diff changeset
136 l = utf_ptr2len(ptr + in);
18
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
137 else
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
138 l = 1;
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
139 cfstr = CFStringCreateWithBytes(NULL, ptr + in, l, from, 0);
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
140 if (cfstr == NULL)
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
141 {
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
142 *d++ = '?';
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
143 out++;
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
144 }
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
145 else
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
146 {
501
ce2181d14aa0 updated for version 7.0139
vimboss
parents: 474
diff changeset
147 if (!CFStringGetCString(cfstr, (char *)d, buflen - out, to))
18
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
148 {
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
149 *d++ = '?';
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
150 out++;
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
151 }
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
152 else
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
153 {
501
ce2181d14aa0 updated for version 7.0139
vimboss
parents: 474
diff changeset
154 i = STRLEN(d);
18
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
155 d += i;
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
156 out += i;
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
157 }
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
158 CFRelease(cfstr);
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
159 }
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
160 in += l;
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
161 }
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
162 *d = NUL;
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
163 if (lenp != NULL)
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
164 *lenp = out;
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
165 return retval;
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
166 }
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
167 CFRelease(cfstr);
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
168 if (lenp != NULL)
501
ce2181d14aa0 updated for version 7.0139
vimboss
parents: 474
diff changeset
169 *lenp = STRLEN(retval);
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
170
18
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
171 return retval;
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
172 }
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
173
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
174 /*
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
175 * Conversion from Apple MacRoman char encoding to UTF-8 or latin1, using
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
176 * standard Carbon framework.
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
177 * Input: "ptr[*sizep]".
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
178 * "real_size" is the size of the buffer that "ptr" points to.
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
179 * output is in-place, "sizep" is adjusted.
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
180 * Returns OK or FAIL.
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
181 */
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
182 int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7811
diff changeset
183 macroman2enc(
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7811
diff changeset
184 char_u *ptr,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7811
diff changeset
185 long *sizep,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7811
diff changeset
186 long real_size)
18
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
187 {
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
188 CFStringRef cfstr;
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
189 CFRange r;
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
190 CFIndex len = *sizep;
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
191
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
192 /* MacRoman is an 8-bit encoding, no need to move bytes to
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
193 * conv_rest[]. */
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
194 cfstr = CFStringCreateWithBytes(NULL, ptr, len,
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
195 kCFStringEncodingMacRoman, 0);
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
196 /*
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
197 * If there is a conversion error, try using another
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
198 * conversion.
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
199 */
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
200 if (cfstr == NULL)
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
201 return FAIL;
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
202
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
203 r.location = 0;
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
204 r.length = CFStringGetLength(cfstr);
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
205 if (r.length != CFStringGetBytes(cfstr, r,
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
206 (enc_utf8) ? kCFStringEncodingUTF8 : kCFStringEncodingISOLatin1,
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
207 0, /* no lossy conversion */
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
208 0, /* not external representation */
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
209 ptr + *sizep, real_size - *sizep, &len))
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
210 {
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
211 CFRelease(cfstr);
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
212 return FAIL;
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
213 }
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
214 CFRelease(cfstr);
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
215 mch_memmove(ptr, ptr + *sizep, len);
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
216 *sizep = len;
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
217
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
218 return OK;
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
219 }
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
220
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
221 /*
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
222 * Conversion from UTF-8 or latin1 to MacRoman.
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
223 * Input: "from[fromlen]"
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
224 * Output: "to[maxtolen]" length in "*tolenp"
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
225 * Unconverted rest in rest[*restlenp].
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
226 * Returns OK or FAIL.
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
227 */
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
228 int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7811
diff changeset
229 enc2macroman(
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7811
diff changeset
230 char_u *from,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7811
diff changeset
231 size_t fromlen,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7811
diff changeset
232 char_u *to,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7811
diff changeset
233 int *tolenp,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7811
diff changeset
234 int maxtolen,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7811
diff changeset
235 char_u *rest,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7811
diff changeset
236 int *restlenp)
18
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
237 {
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
238 CFStringRef cfstr;
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
239 CFRange r;
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
240 CFIndex l;
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
241
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
242 *restlenp = 0;
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
243 cfstr = CFStringCreateWithBytes(NULL, from, fromlen,
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
244 (enc_utf8) ? kCFStringEncodingUTF8 : kCFStringEncodingISOLatin1,
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
245 0);
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
246 while (cfstr == NULL && *restlenp < 3 && fromlen > 1)
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
247 {
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
248 rest[*restlenp++] = from[--fromlen];
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
249 cfstr = CFStringCreateWithBytes(NULL, from, fromlen,
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
250 (enc_utf8) ? kCFStringEncodingUTF8 : kCFStringEncodingISOLatin1,
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
251 0);
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
252 }
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
253 if (cfstr == NULL)
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
254 return FAIL;
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
255
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
256 r.location = 0;
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
257 r.length = CFStringGetLength(cfstr);
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
258 if (r.length != CFStringGetBytes(cfstr, r,
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
259 kCFStringEncodingMacRoman,
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
260 0, /* no lossy conversion */
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
261 0, /* not external representation (since vim
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
262 * handles this internally */
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
263 to, maxtolen, &l))
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
264 {
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
265 CFRelease(cfstr);
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
266 return FAIL;
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
267 }
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
268 CFRelease(cfstr);
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
269 *tolenp = l;
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
270 return OK;
293621502c4d updated for version 7.0010
vimboss
parents:
diff changeset
271 }
20
4ac1dce8dd5e updated for version 7.0012
vimboss
parents: 18
diff changeset
272
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
273 /*
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
274 * Initializes text converters
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
275 */
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
276 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7811
diff changeset
277 mac_conv_init(void)
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
278 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
279 TextEncoding utf8_encoding;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
280 TextEncoding utf8_hfsplus_encoding;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
281 TextEncoding utf8_canon_encoding;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
282 TextEncoding utf16_encoding;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
283
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
284 utf8_encoding = CreateTextEncoding(kTextEncodingUnicodeDefault,
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
285 kTextEncodingDefaultVariant, kUnicodeUTF8Format);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
286 utf8_hfsplus_encoding = CreateTextEncoding(kTextEncodingUnicodeDefault,
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
287 kUnicodeHFSPlusCompVariant, kUnicodeUTF8Format);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
288 utf8_canon_encoding = CreateTextEncoding(kTextEncodingUnicodeDefault,
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
289 kUnicodeCanonicalCompVariant, kUnicodeUTF8Format);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
290 utf16_encoding = CreateTextEncoding(kTextEncodingUnicodeDefault,
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
291 kTextEncodingDefaultVariant, kUnicode16BitFormat);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
292
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
293 if (TECCreateConverter(&gPathConverter, utf8_encoding,
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
294 utf8_hfsplus_encoding) != noErr)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
295 gPathConverter = NULL;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
296
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
297 if (TECCreateConverter(&gUTF16ToUTF8Converter, utf16_encoding,
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
298 utf8_canon_encoding) != noErr)
179
7fd70926e2e1 updated for version 7.0055
vimboss
parents: 168
diff changeset
299 {
7fd70926e2e1 updated for version 7.0055
vimboss
parents: 168
diff changeset
300 /* On pre-10.3, Unicode normalization is not available so
7fd70926e2e1 updated for version 7.0055
vimboss
parents: 168
diff changeset
301 * fall back to non-normalizing converter */
7fd70926e2e1 updated for version 7.0055
vimboss
parents: 168
diff changeset
302 if (TECCreateConverter(&gUTF16ToUTF8Converter, utf16_encoding,
7fd70926e2e1 updated for version 7.0055
vimboss
parents: 168
diff changeset
303 utf8_encoding) != noErr)
7fd70926e2e1 updated for version 7.0055
vimboss
parents: 168
diff changeset
304 gUTF16ToUTF8Converter = NULL;
7fd70926e2e1 updated for version 7.0055
vimboss
parents: 168
diff changeset
305 }
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
306 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
307
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
308 /*
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
309 * Destroys text converters
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
310 */
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
311 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7811
diff changeset
312 mac_conv_cleanup(void)
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
313 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
314 if (gUTF16ToUTF8Converter)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
315 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
316 TECDisposeConverter(gUTF16ToUTF8Converter);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
317 gUTF16ToUTF8Converter = NULL;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
318 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
319
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
320 if (gPathConverter)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
321 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
322 TECDisposeConverter(gPathConverter);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
323 gPathConverter = NULL;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
324 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
325 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
326
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
327 /*
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
328 * Conversion from UTF-16 UniChars to 'encoding'
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1212
diff changeset
329 * The function signature uses the real type of UniChar (as typedef'ed in
82b5078be2dd updated for version 7.2a
vimboss
parents: 1212
diff changeset
330 * CFBase.h) to avoid clashes with X11 header files in the .pro file
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
331 */
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
332 char_u *
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7811
diff changeset
333 mac_utf16_to_enc(
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7811
diff changeset
334 unsigned short *from,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7811
diff changeset
335 size_t fromLen,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7811
diff changeset
336 size_t *actualLen)
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
337 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
338 /* Following code borrows somewhat from os_mswin.c */
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
339 vimconv_T conv;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
340 size_t utf8_len;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
341 char_u *utf8_str;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
342 char_u *result = NULL;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
343
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
344 /* Convert to utf-8 first, works better with iconv */
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
345 utf8_len = 0;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
346 utf8_str = mac_utf16_to_utf8(from, fromLen, &utf8_len);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
347
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
348 if (utf8_str)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
349 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
350 /* We might be called before we have p_enc set up. */
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
351 conv.vc_type = CONV_NONE;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
352
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
353 /* If encoding (p_enc) is any unicode, it is actually in utf-8 (vim
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
354 * internal unicode is always utf-8) so don't convert in such cases */
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
355
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
356 if ((enc_canon_props(p_enc) & ENC_UNICODE) == 0)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
357 convert_setup(&conv, (char_u *)"utf-8",
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
358 p_enc? p_enc: (char_u *)"macroman");
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
359 if (conv.vc_type == CONV_NONE)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
360 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
361 /* p_enc is utf-8, so we're done. */
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
362 result = utf8_str;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
363 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
364 else
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
365 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
366 result = string_convert(&conv, utf8_str, (int *)&utf8_len);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
367 vim_free(utf8_str);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
368 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
369
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
370 convert_setup(&conv, NULL, NULL);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
371
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
372 if (actualLen)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
373 *actualLen = utf8_len;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
374 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
375 else if (actualLen)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
376 *actualLen = 0;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
377
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
378 return result;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
379 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
380
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
381 /*
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
382 * Conversion from 'encoding' to UTF-16 UniChars
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1212
diff changeset
383 * The function return uses the real type of UniChar (as typedef'ed in
82b5078be2dd updated for version 7.2a
vimboss
parents: 1212
diff changeset
384 * CFBase.h) to avoid clashes with X11 header files in the .pro file
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
385 */
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1212
diff changeset
386 unsigned short *
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7811
diff changeset
387 mac_enc_to_utf16(
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7811
diff changeset
388 char_u *from,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7811
diff changeset
389 size_t fromLen,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7811
diff changeset
390 size_t *actualLen)
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
391 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
392 /* Following code borrows somewhat from os_mswin.c */
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
393 vimconv_T conv;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
394 size_t utf8_len;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
395 char_u *utf8_str;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
396 UniChar *result = NULL;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
397 Boolean should_free_utf8 = FALSE;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
398
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
399 do
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
400 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
401 /* Use MacRoman by default, we might be called before we have p_enc
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
402 * set up. Convert to utf-8 first, works better with iconv(). Does
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
403 * nothing if 'encoding' is "utf-8". */
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
404 conv.vc_type = CONV_NONE;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
405 if ((enc_canon_props(p_enc) & ENC_UNICODE) == 0 &&
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
406 convert_setup(&conv, p_enc ? p_enc : (char_u *)"macroman",
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
407 (char_u *)"utf-8") == FAIL)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
408 break;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
409
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
410 if (conv.vc_type != CONV_NONE)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
411 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
412 utf8_len = fromLen;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
413 utf8_str = string_convert(&conv, from, (int *)&utf8_len);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
414 should_free_utf8 = TRUE;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
415 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
416 else
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
417 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
418 utf8_str = from;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
419 utf8_len = fromLen;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
420 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
421
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
422 if (utf8_str == NULL)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
423 break;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
424
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
425 convert_setup(&conv, NULL, NULL);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
426
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
427 result = mac_utf8_to_utf16(utf8_str, utf8_len, actualLen);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
428
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
429 if (should_free_utf8)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
430 vim_free(utf8_str);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
431 return result;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
432 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
433 while (0);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
434
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
435 if (actualLen)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
436 *actualLen = 0;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
437
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
438 return result;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
439 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
440
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
441 /*
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
442 * Converts from UTF-16 UniChars to CFString
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1212
diff changeset
443 * The void * return type is actually a CFStringRef
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
444 */
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1212
diff changeset
445 void *
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7811
diff changeset
446 mac_enc_to_cfstring(
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7811
diff changeset
447 char_u *from,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7811
diff changeset
448 size_t fromLen)
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
449 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
450 UniChar *utf16_str;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
451 size_t utf16_len;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
452 CFStringRef result = NULL;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
453
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
454 utf16_str = mac_enc_to_utf16(from, fromLen, &utf16_len);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
455 if (utf16_str)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
456 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
457 result = CFStringCreateWithCharacters(NULL, utf16_str, utf16_len/sizeof(UniChar));
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
458 vim_free(utf16_str);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
459 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
460
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1212
diff changeset
461 return (void *)result;
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
462 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
463
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
464 /*
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
465 * Converts a decomposed HFS+ UTF-8 path to precomposed UTF-8
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
466 */
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
467 char_u *
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7811
diff changeset
468 mac_precompose_path(
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7811
diff changeset
469 char_u *decompPath,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7811
diff changeset
470 size_t decompLen,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7811
diff changeset
471 size_t *precompLen)
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
472 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
473 char_u *result = NULL;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
474 size_t actualLen = 0;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
475
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
476 if (gPathConverter)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
477 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
478 result = alloc(decompLen);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
479 if (result)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
480 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
481 if (TECConvertText(gPathConverter, decompPath,
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
482 decompLen, &decompLen, result,
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
483 decompLen, &actualLen) != noErr)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
484 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
485 vim_free(result);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
486 result = NULL;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
487 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
488 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
489 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
490
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
491 if (precompLen)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
492 *precompLen = actualLen;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
493
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
494 return result;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
495 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
496
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
497 /*
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
498 * Converts from UTF-16 UniChars to precomposed UTF-8
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
499 */
766
f0d0d3d3a1e2 updated for version 7.0225
vimboss
parents: 501
diff changeset
500 static char_u *
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7811
diff changeset
501 mac_utf16_to_utf8(
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7811
diff changeset
502 UniChar *from,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7811
diff changeset
503 size_t fromLen,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7811
diff changeset
504 size_t *actualLen)
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
505 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
506 ByteCount utf8_len;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
507 ByteCount inputRead;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
508 char_u *result;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
509
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
510 if (gUTF16ToUTF8Converter)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
511 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
512 result = alloc(fromLen * 6 + 1);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
513 if (result && TECConvertText(gUTF16ToUTF8Converter, (ConstTextPtr)from,
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
514 fromLen, &inputRead, result,
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
515 (fromLen*6+1)*sizeof(char_u), &utf8_len) == noErr)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
516 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
517 TECFlushText(gUTF16ToUTF8Converter, result, (fromLen*6+1)*sizeof(char_u), &inputRead);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
518 utf8_len += inputRead;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
519 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
520 else
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
521 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
522 vim_free(result);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
523 result = NULL;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
524 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
525 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
526 else
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
527 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
528 result = NULL;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
529 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
530
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
531 if (actualLen)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
532 *actualLen = result ? utf8_len : 0;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
533
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
534 return result;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
535 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
536
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
537 /*
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
538 * Converts from UTF-8 to UTF-16 UniChars
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
539 */
766
f0d0d3d3a1e2 updated for version 7.0225
vimboss
parents: 501
diff changeset
540 static UniChar *
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7811
diff changeset
541 mac_utf8_to_utf16(
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7811
diff changeset
542 char_u *from,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7811
diff changeset
543 size_t fromLen,
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7811
diff changeset
544 size_t *actualLen)
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
545 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
546 CFStringRef utf8_str;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
547 CFRange convertRange;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
548 UniChar *result = NULL;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
549
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
550 utf8_str = CFStringCreateWithBytes(NULL, from, fromLen,
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
551 kCFStringEncodingUTF8, FALSE);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
552
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
553 if (utf8_str == NULL) {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
554 if (actualLen)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
555 *actualLen = 0;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
556 return NULL;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
557 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
558
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
559 convertRange = CFRangeMake(0, CFStringGetLength(utf8_str));
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
560 result = (UniChar *)alloc(convertRange.length * sizeof(UniChar));
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
561
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
562 CFStringGetCharacters(utf8_str, convertRange, result);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
563
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
564 CFRelease(utf8_str);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
565
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
566 if (actualLen)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
567 *actualLen = convertRange.length * sizeof(UniChar);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
568
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
569 return result;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 20
diff changeset
570 }
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1212
diff changeset
571
82b5078be2dd updated for version 7.2a
vimboss
parents: 1212
diff changeset
572 /*
82b5078be2dd updated for version 7.2a
vimboss
parents: 1212
diff changeset
573 * Sets LANG environment variable in Vim from Mac locale
82b5078be2dd updated for version 7.2a
vimboss
parents: 1212
diff changeset
574 */
82b5078be2dd updated for version 7.2a
vimboss
parents: 1212
diff changeset
575 void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7811
diff changeset
576 mac_lang_init(void)
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7811
diff changeset
577 {
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1212
diff changeset
578 if (mch_getenv((char_u *)"LANG") == NULL)
82b5078be2dd updated for version 7.2a
vimboss
parents: 1212
diff changeset
579 {
82b5078be2dd updated for version 7.2a
vimboss
parents: 1212
diff changeset
580 char buf[20];
82b5078be2dd updated for version 7.2a
vimboss
parents: 1212
diff changeset
581 if (LocaleRefGetPartString(NULL,
82b5078be2dd updated for version 7.2a
vimboss
parents: 1212
diff changeset
582 kLocaleLanguageMask | kLocaleLanguageVariantMask |
82b5078be2dd updated for version 7.2a
vimboss
parents: 1212
diff changeset
583 kLocaleRegionMask | kLocaleRegionVariantMask,
82b5078be2dd updated for version 7.2a
vimboss
parents: 1212
diff changeset
584 sizeof buf, buf) == noErr && *buf)
82b5078be2dd updated for version 7.2a
vimboss
parents: 1212
diff changeset
585 {
82b5078be2dd updated for version 7.2a
vimboss
parents: 1212
diff changeset
586 vim_setenv((char_u *)"LANG", (char_u *)buf);
82b5078be2dd updated for version 7.2a
vimboss
parents: 1212
diff changeset
587 # ifdef HAVE_LOCALE_H
82b5078be2dd updated for version 7.2a
vimboss
parents: 1212
diff changeset
588 setlocale(LC_ALL, "");
82b5078be2dd updated for version 7.2a
vimboss
parents: 1212
diff changeset
589 # endif
82b5078be2dd updated for version 7.2a
vimboss
parents: 1212
diff changeset
590 }
82b5078be2dd updated for version 7.2a
vimboss
parents: 1212
diff changeset
591 }
82b5078be2dd updated for version 7.2a
vimboss
parents: 1212
diff changeset
592 }
766
f0d0d3d3a1e2 updated for version 7.0225
vimboss
parents: 501
diff changeset
593 #endif /* MACOS_CONVERT */