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