|
1 /* |
|
2 * Copyright (c) 2022 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: This module is a plug-in module for Shift-JIS with Pictograph. |
|
15 * Basicaly, Vodafone Pictograph is encoded by ISO2022, |
|
16 * but Japanese FEP needs a pictograph as one character code |
|
17 * in Shift-JIS character code set. |
|
18 * |
|
19 */ |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 // INCLUDE FILES |
|
27 #include "CnvShiftJisDirectmap.h" |
|
28 #include <e32std.h> |
|
29 #include <charconv.h> |
|
30 #include "jisx0201.h" |
|
31 #include "jisx0208.h" |
|
32 #include <convutils.h> |
|
33 |
|
34 #ifdef EKA2 |
|
35 #include <convgeneratedcpp.h> |
|
36 #include <ecom/implementationproxy.h> |
|
37 #include "charactersetconverter.h" |
|
38 #endif // EKA2 |
|
39 |
|
40 const TUint KSingleByteRangeFirstBlockEnd = 0x7f; |
|
41 const TUint KSingleByteRangeSecondBlockStart = 0xa1; |
|
42 const TUint KSingleByteRangeSecondBlockEnd = 0xdf; |
|
43 const TUint KFirstByteRangeFirstBlockStart = 0x81; |
|
44 const TUint KFirstByteRangeFirstBlockEnd = 0x9f; |
|
45 const TUint KFirstByteRangeFirstBlockLength = (KFirstByteRangeFirstBlockEnd+1)-KFirstByteRangeFirstBlockStart; |
|
46 const TUint KFirstByteRangeSecondBlockStart = 0xe0; |
|
47 const TUint KFirstByteRangeSecondBlockEnd = 0xfc; |
|
48 const TUint KSecondByteRangeFirstBlockStart = 0x40; |
|
49 const TUint KSecondByteRangeFirstBlockEnd = 0x7e; |
|
50 const TUint KSecondByteRangeFirstBlockLength = (KSecondByteRangeFirstBlockEnd+1)-KSecondByteRangeFirstBlockStart; |
|
51 const TUint KSecondByteRangeSecondBlockStart = 0x80; |
|
52 const TUint KSecondByteRangeSecondBlockEnd = 0xfc; |
|
53 |
|
54 const TUint KPictoFirstByteStart = 0xF0; |
|
55 const TUint KPictoFirstByteEnd = 0xF9; |
|
56 const TUint KPictoSecondByteStart = 0x40; |
|
57 //const TUint KPictoSecondByteEnd = 0xFB; |
|
58 const TUint KPictoSecondByteEnd = 0xFC; |
|
59 |
|
60 // SecureID for Brower app |
|
61 const TUint32 KBrowserSecureId = 0x10008D39; |
|
62 // Define for converting from YenSign to BackSlash |
|
63 const TUint KCharacterCodeForYenSign = 0x00A5; |
|
64 const TUint KCharacterCodeForBackSlash = 0x005C; |
|
65 |
|
66 #ifdef _DEBUG |
|
67 |
|
68 _LIT(KLitPanicText, "SHIFTJIS_FORFEP"); |
|
69 |
|
70 enum TPanic |
|
71 { |
|
72 EPanicIndexOverflow1=1, |
|
73 EPanicIndexOverflow2, |
|
74 EPanicNothingToConvert1, |
|
75 EPanicNothingToConvert2, |
|
76 EPanicOddNumberOfBytes1, |
|
77 EPanicOddNumberOfBytes2, |
|
78 EPanicBadPointers1, |
|
79 EPanicBadPointers2, |
|
80 EPanicBadPointers3, |
|
81 EPanicBadPointers4, |
|
82 EPanicBadPointers5, |
|
83 EPanicBadPointers6, |
|
84 EPanicBadPointers7, |
|
85 EPanicBadPointers8, |
|
86 EPanicBadPointers9 |
|
87 }; |
|
88 |
|
89 // ============================= LOCAL FUNCTIONS =============================== |
|
90 // ----------------------------------------------------------------------------- |
|
91 // Panic ?description. |
|
92 // ?description |
|
93 // ----------------------------------------------------------------------------- |
|
94 // |
|
95 LOCAL_C void Panic(TPanic aPanic) |
|
96 { |
|
97 User::Panic(KLitPanicText, aPanic); |
|
98 } |
|
99 #endif |
|
100 |
|
101 // ----------------------------------------------------------------------------- |
|
102 // DummyConvertFromIntermediateBufferInPlace ?description. |
|
103 // ?description |
|
104 // Returns: ?value_1: ?description |
|
105 // ?value_n: ?description_line1 |
|
106 // ?description_line2 |
|
107 // ----------------------------------------------------------------------------- |
|
108 // |
|
109 void DummyConvertFromIntermediateBufferInPlace(TInt, TDes8&, TInt& aNumberOfCharactersThatDroppedOut) |
|
110 { |
|
111 aNumberOfCharactersThatDroppedOut = 0; |
|
112 } |
|
113 |
|
114 // ----------------------------------------------------------------------------- |
|
115 // ConvertFromJisX0208ToShiftJisInPlace ?description. |
|
116 // ?description |
|
117 // Returns: ?value_1: ?description |
|
118 // ?value_n: ?description_line1 |
|
119 // ?description_line2 |
|
120 // ----------------------------------------------------------------------------- |
|
121 // |
|
122 void ConvertFromJisX0208ToShiftJisInPlace(TInt aStartPositionInDescriptor, TDes8& aDescriptor, TInt& aNumberOfCharactersThatDroppedOut) |
|
123 { |
|
124 aNumberOfCharactersThatDroppedOut=0; |
|
125 const TInt descriptorLength=aDescriptor.Length(); |
|
126 __ASSERT_DEBUG(descriptorLength>aStartPositionInDescriptor, Panic(EPanicNothingToConvert1)); |
|
127 __ASSERT_DEBUG((descriptorLength-aStartPositionInDescriptor)%2==0, Panic(EPanicOddNumberOfBytes1)); |
|
128 TUint8* pointerToCurrentByte=CONST_CAST(TUint8*, aDescriptor.Ptr()); |
|
129 const TUint8* const pointerToLastByte=pointerToCurrentByte+(descriptorLength-1); |
|
130 pointerToCurrentByte+=aStartPositionInDescriptor; |
|
131 FOREVER |
|
132 { |
|
133 TUint firstByte=*pointerToCurrentByte-0x21; |
|
134 TUint secondByte=*(pointerToCurrentByte+1)-0x21; |
|
135 if (firstByte%2!=0) |
|
136 { |
|
137 secondByte+=94; |
|
138 } |
|
139 firstByte/=2; |
|
140 if (firstByte<KFirstByteRangeFirstBlockLength) |
|
141 { |
|
142 firstByte+=KFirstByteRangeFirstBlockStart; |
|
143 } |
|
144 else |
|
145 { |
|
146 firstByte+=KFirstByteRangeSecondBlockStart-KFirstByteRangeFirstBlockLength; |
|
147 } |
|
148 if (secondByte<KSecondByteRangeFirstBlockLength) |
|
149 { |
|
150 secondByte+=KSecondByteRangeFirstBlockStart; |
|
151 } |
|
152 else |
|
153 { |
|
154 secondByte+=KSecondByteRangeSecondBlockStart-KSecondByteRangeFirstBlockLength; |
|
155 } |
|
156 *pointerToCurrentByte=STATIC_CAST(TUint8, firstByte); |
|
157 ++pointerToCurrentByte; |
|
158 *pointerToCurrentByte=STATIC_CAST(TUint8, secondByte); |
|
159 __ASSERT_DEBUG(pointerToCurrentByte<=pointerToLastByte, Panic(EPanicBadPointers1)); |
|
160 if (pointerToCurrentByte>=pointerToLastByte) |
|
161 { |
|
162 break; |
|
163 } |
|
164 ++pointerToCurrentByte; |
|
165 } |
|
166 } |
|
167 |
|
168 // ----------------------------------------------------------------------------- |
|
169 // NumberOfBytesAbleToConvertToJisX0201 ?description. |
|
170 // ?description |
|
171 // Returns: ?value_1: ?description |
|
172 // ?value_n: ?description_line1 |
|
173 // ?description_line2 |
|
174 // ----------------------------------------------------------------------------- |
|
175 // |
|
176 TInt NumberOfBytesAbleToConvertToJisX0201(const TDesC8& aDescriptor) |
|
177 { |
|
178 const TUint8* pointerToPreviousByte=aDescriptor.Ptr()-1; |
|
179 const TUint8* const pointerToLastByte=pointerToPreviousByte+aDescriptor.Length(); |
|
180 if (pointerToPreviousByte==pointerToLastByte) |
|
181 { |
|
182 return 0; |
|
183 } |
|
184 FOREVER |
|
185 { |
|
186 __ASSERT_DEBUG(pointerToPreviousByte<pointerToLastByte, Panic(EPanicBadPointers2)); |
|
187 const TUint currentByte = *(pointerToPreviousByte+1); |
|
188 if (((currentByte > KSingleByteRangeFirstBlockEnd) |
|
189 && (currentByte < KSingleByteRangeSecondBlockStart)) || |
|
190 (currentByte > KSingleByteRangeSecondBlockEnd)) |
|
191 { |
|
192 break; |
|
193 } |
|
194 __ASSERT_DEBUG(pointerToPreviousByte<pointerToLastByte, Panic(EPanicBadPointers3)); |
|
195 ++pointerToPreviousByte; |
|
196 __ASSERT_DEBUG(pointerToPreviousByte<=pointerToLastByte, Panic(EPanicBadPointers4)); |
|
197 if (pointerToPreviousByte>=pointerToLastByte) |
|
198 { |
|
199 break; |
|
200 } |
|
201 } |
|
202 return (pointerToPreviousByte+1)-aDescriptor.Ptr(); |
|
203 } |
|
204 |
|
205 // ----------------------------------------------------------------------------- |
|
206 // NumberOfBytesAbleToConvertToJisX0208 ?description. |
|
207 // ?description |
|
208 // Returns: ?value_1: ?description |
|
209 // ?value_n: ?description_line1 |
|
210 // ?description_line2 |
|
211 // ----------------------------------------------------------------------------- |
|
212 // |
|
213 TInt NumberOfBytesAbleToConvertToJisX0208(const TDesC8& aDescriptor) |
|
214 { |
|
215 const TUint8* pointerToPreviousByte=aDescriptor.Ptr()-1; |
|
216 const TUint8* const pointerToLastByte=pointerToPreviousByte+aDescriptor.Length(); |
|
217 if (pointerToPreviousByte==pointerToLastByte) |
|
218 { |
|
219 return 0; |
|
220 } |
|
221 FOREVER |
|
222 { |
|
223 __ASSERT_DEBUG(pointerToPreviousByte<pointerToLastByte, Panic(EPanicBadPointers5)); |
|
224 TUint currentByte=*(pointerToPreviousByte+1); |
|
225 if ((currentByte<KFirstByteRangeFirstBlockStart) || |
|
226 ((currentByte>KFirstByteRangeFirstBlockEnd) && (currentByte<KFirstByteRangeSecondBlockStart)) || |
|
227 (currentByte>KFirstByteRangeSecondBlockEnd) || |
|
228 ((currentByte >= KPictoFirstByteStart) && (currentByte <= KPictoFirstByteEnd)) |
|
229 ) |
|
230 { |
|
231 break; |
|
232 } |
|
233 |
|
234 __ASSERT_DEBUG(pointerToPreviousByte<pointerToLastByte, Panic(EPanicBadPointers6)); |
|
235 if (pointerToPreviousByte+1>=pointerToLastByte) |
|
236 { |
|
237 break; |
|
238 } |
|
239 __ASSERT_DEBUG(pointerToPreviousByte+2<=pointerToLastByte, Panic(EPanicBadPointers7)); |
|
240 currentByte=*(pointerToPreviousByte+2); |
|
241 if ((currentByte<KSecondByteRangeFirstBlockStart) || |
|
242 ((currentByte>KSecondByteRangeFirstBlockEnd) && (currentByte<KSecondByteRangeSecondBlockStart)) || |
|
243 (currentByte>KSecondByteRangeSecondBlockEnd)) |
|
244 { |
|
245 break; |
|
246 } |
|
247 pointerToPreviousByte+=2; |
|
248 __ASSERT_DEBUG(pointerToPreviousByte<=pointerToLastByte, Panic(EPanicBadPointers8)); |
|
249 if (pointerToPreviousByte>=pointerToLastByte) |
|
250 { |
|
251 break; |
|
252 } |
|
253 } |
|
254 return (pointerToPreviousByte+1)-aDescriptor.Ptr(); |
|
255 } |
|
256 |
|
257 // ----------------------------------------------------------------------------- |
|
258 // NumberOfBytesAbleToConvertToPictograph ?description. |
|
259 // ?description |
|
260 // Returns: ?value_1: ?description |
|
261 // ?value_n: ?description_line1 |
|
262 // ?description_line2 |
|
263 // ----------------------------------------------------------------------------- |
|
264 // |
|
265 TInt NumberOfBytesAbleToConvertToPictograph(const TDesC8& aDescriptor) |
|
266 { |
|
267 const TUint8* pointerToPreviousByte = aDescriptor.Ptr() - 1; |
|
268 const TUint8* const pointerToLastByte = pointerToPreviousByte + aDescriptor.Length(); |
|
269 |
|
270 for (; pointerToPreviousByte < pointerToLastByte;) |
|
271 { |
|
272 __ASSERT_DEBUG(pointerToPreviousByte < pointerToLastByte, Panic(EPanicBadPointers5)); |
|
273 TUint currentByte = *(pointerToPreviousByte + 1); |
|
274 if ((currentByte < KPictoFirstByteStart) || (currentByte > KPictoFirstByteEnd)) |
|
275 { |
|
276 break; |
|
277 } |
|
278 __ASSERT_DEBUG(pointerToPreviousByte < pointerToLastByte, Panic(EPanicBadPointers6)); |
|
279 if (pointerToPreviousByte + 1 >= pointerToLastByte) |
|
280 { |
|
281 break; |
|
282 } |
|
283 __ASSERT_DEBUG(pointerToPreviousByte + 2 <= pointerToLastByte, Panic(EPanicBadPointers7)); |
|
284 currentByte = *(pointerToPreviousByte + 2); |
|
285 if ((currentByte < KPictoSecondByteStart) || (currentByte> KPictoSecondByteEnd)) |
|
286 { |
|
287 break; |
|
288 } |
|
289 pointerToPreviousByte += 2; |
|
290 __ASSERT_DEBUG(pointerToPreviousByte <= pointerToLastByte, Panic(EPanicBadPointers8)); |
|
291 if (pointerToPreviousByte >= pointerToLastByte) |
|
292 { |
|
293 break; |
|
294 } |
|
295 } |
|
296 return (pointerToPreviousByte + 1)-aDescriptor.Ptr(); |
|
297 } |
|
298 |
|
299 // ----------------------------------------------------------------------------- |
|
300 // DummyConvertToIntermediateBufferInPlace ?description. |
|
301 // ?description |
|
302 // Returns: ?value_1: ?description |
|
303 // ?value_n: ?description_line1 |
|
304 // ?description_line2 |
|
305 // ----------------------------------------------------------------------------- |
|
306 // |
|
307 void DummyConvertToIntermediateBufferInPlace(TDes8&) |
|
308 { |
|
309 } |
|
310 |
|
311 // ----------------------------------------------------------------------------- |
|
312 // ConvertToJisX0208FromShiftJisInPlace ?description. |
|
313 // ?description |
|
314 // Returns: ?value_1: ?description |
|
315 // ?value_n: ?description_line1 |
|
316 // ?description_line2 |
|
317 // ----------------------------------------------------------------------------- |
|
318 // |
|
319 void ConvertToJisX0208FromShiftJisInPlace(TDes8& aDescriptor) |
|
320 { |
|
321 const TInt descriptorLength=aDescriptor.Length(); |
|
322 __ASSERT_DEBUG(descriptorLength>0, Panic(EPanicNothingToConvert2)); |
|
323 __ASSERT_DEBUG(descriptorLength%2==0, Panic(EPanicOddNumberOfBytes2)); |
|
324 TUint8* pointerToCurrentByte=CONST_CAST(TUint8*, aDescriptor.Ptr()); |
|
325 const TUint8* const pointerToLastByte=pointerToCurrentByte+(descriptorLength-1); |
|
326 FOREVER |
|
327 { |
|
328 TUint firstByte=*pointerToCurrentByte; |
|
329 TUint secondByte=*(pointerToCurrentByte+1); |
|
330 if (firstByte<KFirstByteRangeSecondBlockStart) |
|
331 { |
|
332 firstByte-=KFirstByteRangeFirstBlockStart; |
|
333 } |
|
334 else |
|
335 { |
|
336 firstByte-=KFirstByteRangeSecondBlockStart-KFirstByteRangeFirstBlockLength; |
|
337 } |
|
338 if (secondByte<KSecondByteRangeSecondBlockStart) |
|
339 { |
|
340 secondByte-=KSecondByteRangeFirstBlockStart; |
|
341 } |
|
342 else |
|
343 { |
|
344 secondByte-=KSecondByteRangeSecondBlockStart-KSecondByteRangeFirstBlockLength; |
|
345 } |
|
346 firstByte*=2; |
|
347 if (secondByte>=94) |
|
348 { |
|
349 ++firstByte; |
|
350 secondByte-=94; |
|
351 } |
|
352 firstByte+=0x21; |
|
353 secondByte+=0x21; |
|
354 *pointerToCurrentByte=STATIC_CAST(TUint8, firstByte); |
|
355 ++pointerToCurrentByte; |
|
356 *pointerToCurrentByte=STATIC_CAST(TUint8, secondByte); |
|
357 __ASSERT_DEBUG(pointerToCurrentByte<=pointerToLastByte, Panic(EPanicBadPointers9)); |
|
358 if (pointerToCurrentByte>=pointerToLastByte) |
|
359 { |
|
360 break; |
|
361 } |
|
362 ++pointerToCurrentByte; |
|
363 } |
|
364 } |
|
365 |
|
366 // New Interface class |
|
367 class ShiftJisDirectmapImplementation : public CCharacterSetConverterPluginInterface |
|
368 { |
|
369 public: |
|
370 virtual const TDesC8& ReplacementForUnconvertibleUnicodeCharacters(); |
|
371 |
|
372 virtual TInt ConvertFromUnicode( |
|
373 CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters, |
|
374 const TDesC8& aReplacementForUnconvertibleUnicodeCharacters, |
|
375 TDes8& aForeign, |
|
376 const TDesC16& aUnicode, |
|
377 CCnvCharacterSetConverter::TArrayOfAscendingIndices& aIndicesOfUnconvertibleCharacters ); |
|
378 |
|
379 virtual TInt ConvertToUnicode( |
|
380 CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters, |
|
381 TDes16& aUnicode, |
|
382 const TDesC8& aForeign, |
|
383 TInt&, |
|
384 TInt& aNumberOfUnconvertibleCharacters, |
|
385 TInt& aIndexOfFirstByteOfFirstUnconvertibleCharacter ); |
|
386 |
|
387 virtual TBool IsInThisCharacterSetL( |
|
388 TBool& aSetToTrue, |
|
389 TInt& aConfidenceLevel, |
|
390 const TDesC8& ); |
|
391 |
|
392 static ShiftJisDirectmapImplementation* NewL(); |
|
393 |
|
394 virtual ~ShiftJisDirectmapImplementation(); |
|
395 private: |
|
396 ShiftJisDirectmapImplementation(); |
|
397 }; |
|
398 |
|
399 // ----------------------------------------------------------------------------- |
|
400 // ReplacementForUnconvertibleUnicodeCharacters returns the character which |
|
401 // which is used by default as the replacement for unconvertible Unicode |
|
402 // characters. |
|
403 // Returns: a character |
|
404 // ----------------------------------------------------------------------------- |
|
405 // |
|
406 _LIT8(KLit8ShiftJisReplacementForUnconvertibleUnicodeCharacters, "\x81\x48"); |
|
407 const TDesC8& ShiftJisDirectmapImplementation::ReplacementForUnconvertibleUnicodeCharacters() |
|
408 { |
|
409 return KLit8ShiftJisReplacementForUnconvertibleUnicodeCharacters;//CnvShiftJis::ReplacementForUnconvertibleUnicodeCharacters(); |
|
410 } |
|
411 |
|
412 // ----------------------------------------------------------------------------- |
|
413 // ConvertFromUnicode converts from an Unicode string to a Shift-Jis string |
|
414 // with Pictograph. |
|
415 // Returns: The number of unconverted characters left at the end of the input |
|
416 // descriptor |
|
417 // ----------------------------------------------------------------------------- |
|
418 // |
|
419 TInt ShiftJisDirectmapImplementation::ConvertFromUnicode( |
|
420 CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters, |
|
421 const TDesC8& aReplacementForUnconvertibleUnicodeCharacters, |
|
422 TDes8& aForeign, const TDesC16& aUnicode, |
|
423 CCnvCharacterSetConverter::TArrayOfAscendingIndices& aIndicesOfUnconvertibleCharacters) |
|
424 { |
|
425 TFixedArray<CnvUtilities::SCharacterSet, 3> arrayOfCoreCharacterSets; |
|
426 arrayOfCoreCharacterSets[0].iConversionData = &CnvJisX0201::ConversionData(); |
|
427 arrayOfCoreCharacterSets[0].iConvertFromIntermediateBufferInPlace = |
|
428 DummyConvertFromIntermediateBufferInPlace; |
|
429 arrayOfCoreCharacterSets[0].iEscapeSequence = &KNullDesC8; |
|
430 arrayOfCoreCharacterSets[1].iConversionData = &CnvJisX0208::ConversionData(); |
|
431 arrayOfCoreCharacterSets[1].iConvertFromIntermediateBufferInPlace = |
|
432 ConvertFromJisX0208ToShiftJisInPlace; |
|
433 arrayOfCoreCharacterSets[1].iEscapeSequence = &KNullDesC8; |
|
434 arrayOfCoreCharacterSets[2].iConversionData = &CnvShiftJisDirectmap::ConversionData(); |
|
435 arrayOfCoreCharacterSets[2].iConvertFromIntermediateBufferInPlace = |
|
436 DummyConvertFromIntermediateBufferInPlace; |
|
437 arrayOfCoreCharacterSets[2].iEscapeSequence = &KNullDesC8; |
|
438 |
|
439 return CnvUtilities::ConvertFromUnicode(aDefaultEndiannessOfForeignCharacters, |
|
440 aReplacementForUnconvertibleUnicodeCharacters, aForeign, aUnicode, |
|
441 aIndicesOfUnconvertibleCharacters, arrayOfCoreCharacterSets.Array()); |
|
442 } |
|
443 |
|
444 // ----------------------------------------------------------------------------- |
|
445 // ConvertToUnicode converts from a Shift-Jis string with Pictograph to |
|
446 // an Unicode string . |
|
447 // Returns: The number of unconverted bytes left at the end of the input |
|
448 // descriptor |
|
449 // ----------------------------------------------------------------------------- |
|
450 // |
|
451 TInt ShiftJisDirectmapImplementation::ConvertToUnicode( |
|
452 CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters, |
|
453 TDes16& aUnicode, const TDesC8& aForeign, TInt&, |
|
454 TInt& aNumberOfUnconvertibleCharacters, |
|
455 TInt& aIndexOfFirstByteOfFirstUnconvertibleCharacter) |
|
456 { |
|
457 TFixedArray<CnvUtilities::SMethod, 3> arrayOfCoreMethods; |
|
458 arrayOfCoreMethods[0].iNumberOfBytesAbleToConvert = |
|
459 NumberOfBytesAbleToConvertToJisX0201; |
|
460 arrayOfCoreMethods[0].iConvertToIntermediateBufferInPlace = |
|
461 DummyConvertToIntermediateBufferInPlace; |
|
462 arrayOfCoreMethods[0].iConversionData = &CnvJisX0201::ConversionData(); |
|
463 arrayOfCoreMethods[0].iNumberOfBytesPerCharacter = 1; |
|
464 arrayOfCoreMethods[0].iNumberOfCoreBytesPerCharacter = 1; |
|
465 arrayOfCoreMethods[1].iNumberOfBytesAbleToConvert = |
|
466 NumberOfBytesAbleToConvertToPictograph; |
|
467 arrayOfCoreMethods[1].iConvertToIntermediateBufferInPlace = |
|
468 DummyConvertToIntermediateBufferInPlace; |
|
469 arrayOfCoreMethods[1].iConversionData = &CnvShiftJisDirectmap::ConversionData(); |
|
470 arrayOfCoreMethods[1].iNumberOfBytesPerCharacter = 2; |
|
471 arrayOfCoreMethods[1].iNumberOfCoreBytesPerCharacter = 2; |
|
472 arrayOfCoreMethods[2].iNumberOfBytesAbleToConvert = |
|
473 NumberOfBytesAbleToConvertToJisX0208; |
|
474 arrayOfCoreMethods[2].iConvertToIntermediateBufferInPlace = |
|
475 ConvertToJisX0208FromShiftJisInPlace; |
|
476 arrayOfCoreMethods[2].iConversionData = &CnvJisX0208::ConversionData(); |
|
477 arrayOfCoreMethods[2].iNumberOfBytesPerCharacter = 2; |
|
478 arrayOfCoreMethods[2].iNumberOfCoreBytesPerCharacter = 2; |
|
479 |
|
480 TInt unconvert = CnvUtilities::ConvertToUnicodeFromHeterogeneousForeign( |
|
481 aDefaultEndiannessOfForeignCharacters, aUnicode, aForeign, |
|
482 aNumberOfUnconvertibleCharacters, |
|
483 aIndexOfFirstByteOfFirstUnconvertibleCharacter, |
|
484 arrayOfCoreMethods.Array()); |
|
485 |
|
486 // The following is specific impelementation for brower. |
|
487 // If brower app calls this API, the yen sign code(0xA5) |
|
488 // must be converted to backslash code(0x5C). |
|
489 // Becasue Javascript supports backslash code ony. |
|
490 TBool browserProcess = (RProcess().SecureId().iId == KBrowserSecureId); |
|
491 if (browserProcess && aUnicode.Length() > 0) |
|
492 { |
|
493 const TUint16* pB = aUnicode.Ptr(); |
|
494 const TUint16* pbase = pB; |
|
495 const TUint16* pE = pB + aUnicode.Length() -1; |
|
496 while (pE>=pbase) |
|
497 { |
|
498 if (*pbase == KCharacterCodeForYenSign) |
|
499 { |
|
500 aUnicode[pbase - pB] = KCharacterCodeForBackSlash; |
|
501 } |
|
502 pbase++; |
|
503 } |
|
504 } |
|
505 |
|
506 return unconvert; |
|
507 } |
|
508 |
|
509 // ----------------------------------------------------------------------------- |
|
510 // IsInThisCharacterSetL tests whether the aSample is Shift-JIS or not. |
|
511 // But, This .cpl is only used for FEP. |
|
512 // So, it's not need to correspond auto code detection. |
|
513 // Returns: EFalse: ?description |
|
514 // ----------------------------------------------------------------------------- |
|
515 // |
|
516 TBool ShiftJisDirectmapImplementation::IsInThisCharacterSetL(TBool& /*aSetToTrue*/, TInt& /*aConfidenceLevel*/, |
|
517 const TDesC8& /*aSample*/) |
|
518 { |
|
519 return EFalse; |
|
520 } |
|
521 |
|
522 ShiftJisDirectmapImplementation* ShiftJisDirectmapImplementation::NewL() |
|
523 { |
|
524 ShiftJisDirectmapImplementation* self = new(ELeave) ShiftJisDirectmapImplementation; |
|
525 return self; |
|
526 } |
|
527 |
|
528 ShiftJisDirectmapImplementation::ShiftJisDirectmapImplementation() |
|
529 { |
|
530 //default constructor.. do nothing |
|
531 } |
|
532 |
|
533 ShiftJisDirectmapImplementation::~ShiftJisDirectmapImplementation() |
|
534 { |
|
535 //default destructor .. do nothing |
|
536 } |
|
537 |
|
538 // ECOM CREATION FUNCTION |
|
539 const TImplementationProxy ImplementationTable[] = |
|
540 { |
|
541 // Note: This is the same UID as defined in old mmp-file |
|
542 // Used also in 12221212.rss ( implementation_uid ) |
|
543 IMPLEMENTATION_PROXY_ENTRY( 0x101F8691, ShiftJisDirectmapImplementation::NewL ) |
|
544 }; |
|
545 |
|
546 EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount ) |
|
547 { |
|
548 aTableCount = sizeof( ImplementationTable ) / sizeof(TImplementationProxy); |
|
549 return ImplementationTable; |
|
550 } |
|
551 |
|
552 // End of File |