blob: 8041c15e296bccbaaf22158f04a3e01cbb22aa29 [file] [log] [blame]
yu.dongc33b3072024-08-21 23:14:49 -07001/*****************************************************************************
2* Copyright Statement:
3* --------------------
4* This software is protected by Copyright and the information contained
5* herein is confidential. The software may not be copied and the information
6* contained herein may not be used or disclosed except with the written
7* permission of MediaTek Inc. (C) 2005
8*
9* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
10* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
11* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
12* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
13* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
14* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
15* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
16* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
17* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
18* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
19* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
20* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
21*
22* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
23* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
24* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
25* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
26* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
27*
28* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
29* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
30* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
31* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
32* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
33*
34*****************************************************************************/
35
36/*******************************************************************************
37 * Filename:
38 * ---------
39 * Conversions.h
40 *
41 * Project:
42 * --------
43 * MAUI
44 *
45 * Description:
46 * ------------
47 * This file defines constant, enum value, and structures for converting
48 * realted utilities.
49 *
50 * Author:
51 * -------
52 * -------
53 *
54 *==============================================================================
55 * HISTORY
56 * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
57 *------------------------------------------------------------------------------
58 * removed!
59 *
60 * removed!
61 * removed!
62 * removed!
63 *
64 * removed!
65 * removed!
66 * removed!
67 *
68 * removed!
69 * removed!
70 * removed!
71 *
72 * removed!
73 * removed!
74 * removed!
75 *
76 * removed!
77 * removed!
78 * removed!
79 *
80 * removed!
81 * removed!
82 * removed!
83 *
84 * removed!
85 * removed!
86 * removed!
87 *
88 * removed!
89 * removed!
90 * removed!
91 *
92 * removed!
93 * removed!
94 * removed!
95 *
96 * removed!
97 * removed!
98 * removed!
99 *
100 * removed!
101 * removed!
102 * removed!
103 *
104 * removed!
105 * removed!
106 * removed!
107 *
108 * removed!
109 * removed!
110 * removed!
111 *
112 * removed!
113 * removed!
114 * removed!
115 *
116 * removed!
117 * removed!
118 * removed!
119 *
120 * removed!
121 * removed!
122 * removed!
123 *
124 * removed!
125 * removed!
126 * removed!
127 *
128 * removed!
129 * removed!
130 * removed!
131 *
132 * removed!
133 * removed!
134 * removed!
135 *
136 * removed!
137 * removed!
138 * removed!
139 *
140 * removed!
141 * removed!
142 * removed!
143 *
144 * removed!
145 * removed!
146 * removed!
147 *
148 * removed!
149 * removed!
150 * removed!
151 *
152 * removed!
153 * removed!
154 * removed!
155 *
156 * removed!
157 * removed!
158 * removed!
159 *
160 * removed!
161 * removed!
162 * removed!
163 *
164 * removed!
165 * removed!
166 * removed!
167 *
168 * removed!
169 * removed!
170 * removed!
171 *
172 * removed!
173 * removed!
174 * removed!
175 *
176 * removed!
177 * removed!
178 * removed!
179 *
180 * removed!
181 * removed!
182 * removed!
183 *
184 * removed!
185 * removed!
186 * removed!
187 *
188 * removed!
189 * removed!
190 * removed!
191 *
192 * removed!
193 * removed!
194 * removed!
195 *
196 * removed!
197 * removed!
198 * removed!
199 *
200 * removed!
201 * removed!
202 * removed!
203 *
204 * removed!
205 * removed!
206 * removed!
207 *
208 * removed!
209 * removed!
210 * removed!
211 *
212 * removed!
213 * removed!
214 * removed!
215 *
216 *------------------------------------------------------------------------------
217 * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
218 *==============================================================================
219 *******************************************************************************/
220#ifndef _MMI_CONVERSIONS_H
221#define _MMI_CONVERSIONS_H
222#include "kal_public_api.h" //MSBB change #include "kal_release.h"
223
224#if !defined(NEPTUNE_MMI)
225#include "kal_general_types.h"
226#endif
227
228#ifndef FALSE
229 #define FALSE 0
230#endif
231#define TRUE 1
232#define UNKOWN_UCS2_CHAR 0xFFEB
233
234typedef enum
235{
236 BIG_5_ENCODING_TYPE,
237 GB2312_ENCODING_TYPE,
238 HKSCS_ENCODING_TYPE,
239 NO_OF_TEXT_ENCODING
240} TextEncodingEnum;
241
242typedef struct
243{
244 short start;
245 short end;
246} key_index_t;
247
248/*-- function prototypes --*/
249
250extern kal_uint16 mmi_chset_wchar_to_ucs2(kal_uint16 encode_char, TextEncodingEnum encoding);
251extern kal_uint16 mmi_chset_ucs2_to_wchar(kal_uint16 ucs2_char, TextEncodingEnum encoding);
252
253extern kal_uint16 mmi_chset_text_to_ucs2_str(
254 kal_uint8 *dest,
255 kal_int32 dest_size,
256 kal_uint8 *src,
257 TextEncodingEnum encoding);
258extern kal_uint16 mmi_chset_text_to_ucs2_str_ex(
259 kal_uint8 *dest,
260 kal_int32 dest_size,
261 kal_uint8 *src,
262 TextEncodingEnum encoding,
263 kal_uint32 *src_end_pos);
264
265extern kal_uint16 mmi_chset_ucs2_to_text_str(
266 kal_uint8 *dest,
267 kal_int32 dest_size,
268 kal_uint8 *src,
269 TextEncodingEnum encoding);
270extern kal_uint16 mmi_chset_ucs2_to_text_str_ex(
271 kal_uint8 *dest,
272 kal_int32 dest_size,
273 kal_uint8 *src,
274 TextEncodingEnum encoding,
275 kal_uint32 *src_end_pos);
276
277extern kal_uint8 mmi_chset_is_text_in_str(kal_uint8 *src);
278
279/*-- exposed global data --*/
280
281extern const kal_uint8 *g_ucs2_to_encode_key_MSB[NO_OF_TEXT_ENCODING];
282extern const kal_uint8 *g_encode_to_ucs2_key_MSB[NO_OF_TEXT_ENCODING];
283extern const kal_uint16 *g_ucs2_to_encode_table[NO_OF_TEXT_ENCODING];
284extern const kal_uint16 *g_encode_to_ucs2_table[NO_OF_TEXT_ENCODING];
285extern const kal_uint16 g_unknown_encode_char[NO_OF_TEXT_ENCODING];
286extern const kal_uint16 *g_text_encoding_name[NO_OF_TEXT_ENCODING];
287
288#define CHSET_MAX_COUNT 25
289#define CHSET_BIT_WORD_16 16
290#define CHSET_BIT_WORD_8 8
291#define CHSET_TMP_BUFF_SIZE 2048 /* the size of the temp buffer in mmi_chset_convert() */
292
293/* Supported Guess Charsets */
294#define CHSET_GUESS_ALL 0x00000000
295#define CHSET_GUESS_UTF8 0x00000001
296#define CHSET_GUESS_UTF16LE 0x00000002
297#define CHSET_GUESS_UTF16BE 0x00000004
298#define CHSET_GUESS_UCS2 0x00000008
299#define CHSET_GUESS_GB2312 0x00000010
300#define CHSET_GUESS_BIG5 0x00000020
301#define CHSET_GUESS_WESTERN_ISO 0x00000040
302#define CHSET_GUESS_HKSCS 0x00000080
303
304#define CHSET_LANG_MAP_SIZE 5
305
306/* Enum of all supported charsets*/
307typedef enum
308{
309 CHSET_BASE,
310 MMI_CHSET_BASE = CHSET_BASE,
311 CHSET_ASCII,
312 MMI_CHSET_ASCII = CHSET_ASCII, // ASCII
313 CHSET_ARABIC_ISO,
314 MMI_CHSET_ARABIC_ISO = CHSET_ARABIC_ISO, // ISO 8859-6 (Arabic)
315 CHSET_ARABIC_WIN,
316 MMI_CHSET_ARABIC_WIN = CHSET_ARABIC_WIN, // Windows-1256 (Arabic)
317 CHSET_PERSIAN_CP1097,
318 MMI_CHSET_PERSIAN_CP1097 = CHSET_PERSIAN_CP1097, // CP1097 (Persian)
319 CHSET_PERSIAN_CP1098,
320 MMI_CHSET_PERSIAN_CP1098 = CHSET_PERSIAN_CP1098, // CP1098 (Persian)
321 CHSET_BALTIC_ISO,
322 MMI_CHSET_BALTIC_ISO = CHSET_BALTIC_ISO, // ISO-8859-4 (Baltic language group)
323 CHSET_BALTIC_WIN,
324 MMI_CHSET_BALTIC_WIN = CHSET_BALTIC_WIN, // Windows-1257 (Baltic language group)
325 CHSET_CEURO_ISO,
326 MMI_CHSET_CEURO_ISO = CHSET_CEURO_ISO, // ISO-8859-2 (Central european language group)
327 CHSET_CEURO_WIN,
328 MMI_CHSET_CEURO_WIN = CHSET_CEURO_WIN, // Windows-1250 (Central european language group)
329 CHSET_CYRILLIC_ISO,
330 MMI_CHSET_CYRILLIC_ISO = CHSET_CYRILLIC_ISO, // ISO-8859-5 (Cyrillic script based languages)
331 CHSET_CYRILLIC_WIN,
332 MMI_CHSET_CYRILLIC_WIN = CHSET_CYRILLIC_WIN, // Windows-1251 (Cyrillic script)
333 CHSET_GREEK_ISO,
334 MMI_CHSET_GREEK_ISO = CHSET_GREEK_ISO, // ISO-8859-7 (Greek)
335 CHSET_GREEK_WIN,
336 MMI_CHSET_GREEK_WIN = CHSET_GREEK_WIN, // Windows-1253 (Greek)
337 CHSET_HEBREW_ISO,
338 MMI_CHSET_HEBREW_ISO = CHSET_HEBREW_ISO, // ISO-8859-8 (Hebrew)
339 CHSET_HEBREW_WIN,
340 MMI_CHSET_HEBREW_WIN = CHSET_HEBREW_WIN, // Windows-1255 (Hebrew)
341 CHSET_LATIN_ISO,
342 MMI_CHSET_LATIN_ISO = CHSET_LATIN_ISO, // ISO-8859-4 (North european language group)
343 CHSET_NORDIC_ISO,
344 MMI_CHSET_NORDIC_ISO = CHSET_NORDIC_ISO, // ISO-8859-10 (Nordic language group)
345 CHSET_SEURO_ISO,
346 MMI_CHSET_SEURO_ISO = CHSET_SEURO_ISO, // ISO-8859-3 (South european language group)
347 CHSET_TURKISH_ISO,
348 MMI_CHSET_TURKISH_ISO = CHSET_TURKISH_ISO, // ISO-8859-9 (Turkish)
349 CHSET_TURKISH_WIN,
350 MMI_CHSET_TURKISH_WIN = CHSET_TURKISH_WIN, // Windows-1254 (Turkish)
351 CHSET_WESTERN_ISO,
352 MMI_CHSET_WESTERN_ISO = CHSET_WESTERN_ISO, // ISO-8859-1 (Latin script based languages)
353 CHSET_ARMENIAN_ISO,
354 MMI_CHSET_ARMENIAN_ISO = CHSET_ARMENIAN_ISO, // ISO-10585 ARMSCII (Armenian)
355 CHSET_THAI_WIN,
356 MMI_CHSET_THAI_WIN = CHSET_THAI_WIN, // Windows-874 (Thai)
357 CHSET_VIETNAMESE_WIN,
358 MMI_CHSET_VIETNAMESE_WIN = CHSET_VIETNAMESE_WIN, // Windows-1258 (Vietnamese)
359 CHSET_KOI8_R,
360 MMI_CHSET_KOI8_R = CHSET_KOI8_R, // KOI8-russian
361 CHSET_TIS_620,
362 MMI_CHSET_TIS_620 = CHSET_TIS_620, // Thai Industrial Standard 620
363 CHSET_WESTERN_WIN,
364 MMI_CHSET_WESTERN_WIN = CHSET_WESTERN_WIN, // Windows-1252 (Latin script based languages)
365
366 /* Add new (8-bit) encodings above this line */
367
368 CHSET_BIG5,
369 MMI_CHSET_BIG5 = CHSET_BIG5, // Big5 (Traditional chinese)
370 CHSET_GB2312,
371 MMI_CHSET_GB2312 = CHSET_GB2312, // GB2312 (Simplified chinese)
372 CHSET_HKSCS,
373 MMI_CHSET_HKSCS = CHSET_HKSCS, // HKSCS 2004 (Hong Kong chinese)
374 CHSET_SJIS,
375 MMI_CHSET_SJIS = CHSET_SJIS, // SJIS (Japanese)
376 CHSET_GB18030,
377 MMI_CHSET_GB18030 = CHSET_GB18030, // GB18030 (Simplified chinese-extended)
378 CHSET_UTF7,
379 MMI_CHSET_UTF7 = CHSET_UTF7, // UTF-7
380 CHSET_EUCKR,
381 MMI_CHSET_EUCKR = CHSET_EUCKR, // Extended Unix Code - korean
382
383 /* Place all CJK encodings above this one */
384
385 CHSET_UTF16LE,
386 MMI_CHSET_UTF16LE = CHSET_UTF16LE, // UTF-16LE
387 CHSET_UTF16BE,
388 MMI_CHSET_UTF16BE = CHSET_UTF16BE, // UTF-16BE
389 CHSET_UTF8,
390 MMI_CHSET_UTF8 = CHSET_UTF8, // UTF-8
391 CHSET_UCS2,
392 MMI_CHSET_UCS2 = CHSET_UCS2, // UCS2
393 CHSET_TOTAL,
394 MMI_CHSET_TOTAL = CHSET_TOTAL
395} mmi_chset_enum, chset_enum;
396
397/* do not change the order */
398
399/* Enum of all supporte charset pairs */
400
401typedef enum _ENCODING_SCHEMES_ENUM
402{
403 BASE_ENCODING_SCHEME,
404
405 ASCII_TO_UCS2,
406 UCS2_TO_ASCII,
407
408 ARABIC_ISO_TO_UCS2,
409 UCS2_TO_ARABIC_ISO,
410
411 ARABIC_WINDOWS_TO_UCS2,
412 UCS2_TO_ARABIC_WINDOWS,
413
414 PERSIAN_CP1097_TO_UCS2,
415 UCS2_TO_PERSIAN_CP1097,
416
417 PERSIAN_CP1098_TO_UCS2,
418 UCS2_TO_PERSIAN_CP1098,
419
420 BALTIC_ISO_TO_UCS2,
421 UCS2_TO_BALTIC_ISO,
422
423 BALTIC_WINDOWS_TO_UCS2,
424 UCS2_TO_BALTIC_WINDOWS,
425
426 CENTRAL_EUROPEAN_ISO_TO_UCS2,
427 UCS2_TO_CENTRAL_EUROPEAN_ISO,
428
429 CENTRAL_EUROPEAN_WINDOWS_TO_UCS2,
430 UCS2_TO_CENTRAL_EUROPEAN_WINDOWS,
431
432 CYRILLIC_ISO_TO_UCS2,
433 UCS2_TO_CYRILLIC_ISO,
434
435 CYRILLIC_WINDOWS_TO_UCS2,
436 UCS2_TO_CYRILLIC_WINDOWS,
437
438 GREEK_ISO_TO_UCS2,
439 UCS2_TO_GREEK_ISO,
440
441 GREEK_WINDOWS_TO_UCS2,
442 UCS2_TO_GREEK_WINDOWS,
443
444 HEBREW_ISO_TO_UCS2,
445 UCS2_TO_HEBREW_ISO,
446
447 HEBREW_WINDOWS_TO_UCS2,
448 UCS2_TO_HEBREW_WINDOWS,
449
450 LATIN_ISO_TO_UCS2,
451 UCS2_TO_LATIN_ISO,
452
453 NORDIC_ISO_TO_UCS2,
454 UCS2_TO_NORDIC_ISO,
455
456 SOUTH_EUROPEAN_ISO_TO_UCS2,
457 UCS2_TO_SOUTH_EUROPEAN_ISO,
458
459 TURKISH_ISO_TO_UCS2,
460 UCS2_TO_TURKISH_ISO,
461
462 TURKISH_WINDOWS_TO_UCS2,
463 UCS2_TO_TURKISH_WINDOWS,
464
465 WESTERN_ISO_TO_UCS2,
466 UCS2_TO_WESTERN_ISO,
467
468 ARMENIAN_ISO_TO_UCS2,
469 UCS2_TO_ARMENIAN_ISO,
470
471 THAI_WINDOWS_TO_UCS2,
472 UCS2_TO_THAI_WINDOWS,
473
474 VIETNAMESE_WINDOWS_TO_UCS2,
475 UCS2_TO_VIETNAMESE_WINDOWS,
476
477 KOI8_R_TO_UCS2,
478 UCS2_TO_KOI8_R,
479
480 TIS_620_TO_UCS2,
481 UCS2_TO_TIS_620,
482
483 WESTERN_WINDOWS_TO_UCS2,
484 UCS2_TO_WESTERN_WINDOWS,
485
486 /* Add new (8-bit) encodings above this line */
487 BIG5_TO_UCS2,
488 UCS2_TO_BIG5,
489
490 GB2312_TO_UCS2,
491 UCS2_TO_GB2312,
492
493 HKSCS_TO_UCS2,
494 UCS2_TO_HKSCS,
495
496 SJIS_TO_UCS2,
497 UCS2_TO_SJIS,
498
499 GB18030_TO_UCS2,
500 UCS2_TO_GB18030,
501
502 UTF7_TO_UCS2,
503 UCS2_TO_UTF7,
504
505 EUCKR_WINDOWS_TO_UCS2,
506 UCS2_TO_EUCKR_WINDOWS,
507
508 /* Place all CJK encodings above this one */
509 UTF16LE_TO_UCS2,
510 UCS2_TO_UTF16LE,
511
512 UTF16BE_TO_UCS2,
513 UCS2_TO_UTF16BE,
514
515 UTF8_TO_UCS2,
516 UCS2_TO_UTF8,
517
518 CHSET_PAIR_TOTAL
519} mmi_chset_pair_enum;
520
521/* Global variable to hold curent default encoding in phone
522 This value will be updated by MMI phone setup module */
523extern mmi_chset_enum g_chset_text_encoding;
524
525extern kal_uint16 EncodingDecoding(
526 mmi_chset_pair_enum Scheme,
527 char *pOutBuffer,
528 char *pInBuffer,
529 kal_int32 dest_size,
530 kal_uint32 *src_end_pos);
531
532/*****************************************************************************
533 * FUNCTION
534 * mmi_chset_init
535 * DESCRIPTION
536 * Routine for initializing the related data structures of the various encoding types
537 * PARAMETERS
538 * void
539 * RETURNS
540 * void
541 *****************************************************************************/
542extern void mmi_chset_init(void);
543
544/*****************************************************************************
545 * FUNCTION
546 * mmi_chset_convert
547 * DESCRIPTION
548 * Convert string between 2 character sets. (will add the terminate character)
549 * PARAMETERS
550 * src_type : [IN] Charset type of source
551 * dest_type : [IN] Charset type of destination
552 * src_buff : [IN] Buffer stores source string
553 * dest_buff : [OUT] Buffer stores destination string
554 * dest_size : [IN] Size of destination buffer (bytes)
555 * RETURNS
556 * Length of destination string, including null terminator. (bytes)
557 *****************************************************************************/
558extern kal_int32 mmi_chset_convert(
559 mmi_chset_enum src_type,
560 mmi_chset_enum dest_type,
561 char *src_buff,
562 char *dest_buff,
563 kal_int32 dest_size);
564
565extern kal_int32 mmi_chset_convert_ex(
566 mmi_chset_enum src_type,
567 mmi_chset_enum dest_type,
568 char *src_buff,
569 char *dest_buff,
570 kal_int32 dest_size,
571 kal_uint32 *src_end_pos);
572
573extern kal_int32 chset_convert(
574 chset_enum src_type,
575 chset_enum dest_type,
576 char *src_buff,
577 char *dest_buff,
578 kal_int32 dest_size);
579
580extern kal_int32 chset_convert_ex(
581 chset_enum src_type,
582 chset_enum dest_type,
583 char *src_buff,
584 char *dest_buff,
585 kal_int32 dest_size,
586 kal_uint32 *src_end_pos);
587
588/*****************************************************************************
589 * FUNCTION
590 * mmi_chset_use_space_for_unknown_character
591 * DESCRIPTION
592 * It's a property of charset conversion module. Setting it up would cause invalid character values behave as 'space' character.
593 * It is applicable only with ideographic charsets.
594 * PARAMETERS
595 * void
596 * RETURNS
597 * void
598 *****************************************************************************/
599extern void mmi_chset_use_space_for_unknown_character(void);
600
601/*****************************************************************************
602 * FUNCTION
603 * mmi_chset_use_space_for_unknown_character
604 * DESCRIPTION
605 * It's a property of charset conversion module. Setting it up would cause invalid character values behave as 0xFFFF.
606 * It is applicable only with ideographic charsets.
607 * PARAMETERS
608 * void
609 * RETURNS
610 * void
611 *****************************************************************************/
612extern void mmi_chset_do_not_use_space_for_unknown_character(void);
613
614extern kal_int32 mmi_chset_convert_with_src_length(
615 mmi_chset_enum src_type,
616 mmi_chset_enum dest_type,
617 char *src_buff,
618 kal_int32 src_size,
619 char *dest_buff,
620 kal_int32 dest_size);
621extern kal_uint16 UCS2_TO_WCHAR(kal_uint16 src_char);
622
623extern void mmi_chset_mixed_text_to_ucs2_str(
624 kal_uint8 *dest,
625 kal_int16 dest_size,
626 kal_uint8 *src,
627 mmi_chset_enum encoding);
628extern void mmi_chset_mixed_text_to_ucs2_str_ex(
629 kal_uint8 *dest,
630 kal_int16 dest_size,
631 kal_uint8 *src,
632 mmi_chset_enum encoding,
633 kal_uint32 *src_end_pos);
634
635extern kal_int32 mmi_chset_text_to_ucs2(kal_uint8 *dest, kal_int32 dest_size, kal_uint8 *src);
636extern kal_int32 mmi_chset_text_to_ucs2_ex(
637 kal_uint8 *dest,
638 kal_int32 dest_size,
639 kal_uint8 *src,
640 kal_uint32 *src_end_pos);
641
642/*****************************************************************************
643 * FUNCTION
644 * mmi_chset_get_char_size_of_charset
645 * DESCRIPTION
646 * Get maximum number of bytes, that the given charset can take for a single character
647 * PARAMETERS
648 * mmi_chset_enum : [IN] Charset
649 * RETURNS
650 * Maximum number of bytes, that chset can take for a single character
651 *****************************************************************************/
652extern kal_int32 mmi_chset_get_char_size_of_charset(mmi_chset_enum chset);
653
654extern kal_int32 mmi_chset_get_char_size_of_default_charset(void);
655
656/* UTF8 related */
657
658/*****************************************************************************
659 * FUNCTION
660 * mmi_chset_utf8_to_ucs2
661 * DESCRIPTION
662 * Convert single UTF8 character to UCS2
663 * PARAMETERS
664 * ucs2 : [OUT] Output buffer (Needs at least 2 bytes)
665 * utf8 : [IN] Input buffer (Can have 1 to 4 bytes, depending ont he character)
666 * RETURNS
667 * Number of input bytes used
668 *****************************************************************************/
669extern kal_int32 mmi_chset_utf8_to_ucs2(kal_uint8 *ucs2, kal_uint8 *utf8);
670
671/*****************************************************************************
672 * FUNCTION
673 * mmi_chset_ucs2_to_utf8
674 * DESCRIPTION
675 * Convert single UCS2 character to UTF8
676 * PARAMETERS
677 * utf8 : [OUT]Output buffer (Needs 1 to 4 bytes, depending ont he character)
678 * ucs2 : [IN] Input
679 * RETURNS
680 * Number of bytes taken in utf8
681 *****************************************************************************/
682extern kal_int32 mmi_chset_ucs2_to_utf8(kal_uint8 *utf8, kal_uint16 ucs2);
683
684extern kal_int32 mmi_chset_utf8_to_ucs2_string(kal_uint8 *dest, kal_int32 dest_size, kal_uint8 *src);
685extern kal_int32 mmi_chset_utf8_to_ucs2_string_ex(
686 kal_uint8 *dest,
687 kal_int32 dest_size,
688 kal_uint8 *src,
689 kal_uint32 *src_end_pos);
690extern kal_int32 mmi_chset_ucs2_to_utf8_string(kal_uint8 *dest, kal_int32 dest_size, kal_uint8 *src);
691extern kal_int32 mmi_chset_ucs2_to_utf8_string_ex(
692 kal_uint8 *dest,
693 kal_int32 dest_size,
694 kal_uint8 *src,
695 kal_uint32 *src_end_pos);
696
697/*****************************************************************************
698 * FUNCTION
699 * mmi_chset_utf8_strlen
700 * DESCRIPTION
701 * Get string length of a UTF8 encoded buffer
702 * PARAMETERS
703 * s : [IN] Input buffer
704 * RETURNS
705 * Number of valid characters
706 *****************************************************************************/
707extern kal_int32 mmi_chset_utf8_strlen(const kal_uint8 *s);
708
709/*****************************************************************************
710 * FUNCTION
711 * mmi_chset_get_charset_id
712 * DESCRIPTION
713 * This function is used for get the charset id for the given charset name string. It's a name resolver for charsets.
714 * PARAMETERS
715 * chset_name : [IN] Charset name
716 * chset_id_p : [OUT] Charset ID
717 * RETURNS
718 * retrun KAL_TRUE if succeed, otherwise return KAL_FALSE
719 *****************************************************************************/
720extern kal_bool mmi_chset_get_charset_id(const kal_int8 *chset_name, mmi_chset_enum *chset_id_p);
721
722extern kal_bool chset_get_charset_id(const kal_int8 *chset_name, chset_enum *chset_id_p);
723
724/*****************************************************************************
725 * FUNCTION
726 * chset_get_preferred_mime_name
727 * DESCRIPTION
728 * This function is used for get the preferred MIME name of character set via
729 * the character set id.
730 * PARAMETERS
731 * chset_id : [IN] Character set id.
732 * RETURNS
733 * If successful, retrun the const pointer to the character set name,
734 * otherwise return NULL
735 *****************************************************************************/
736extern const kal_int8 *chset_get_preferred_mime_name(chset_enum chset_id);
737
738/*****************************************************************************
739 * FUNCTION
740 * mmi_chset_get_utf_byte_order
741 * DESCRIPTION
742 * The function is used for get the byte order via the byte order mark .
743 * PARAMETERS
744 * str_bom : [IN] The byte order mark.
745 * RETURNS
746 * returns MMI_CHSET_UTF16LE if the stream is little-endian
747 * returns MMI_CHSET_UTF16BE if the stream is big-endian
748 * returns MMI_CHSET_UTF8 if the input BOM is a UTF-8's BOM
749 * Otherwise returns -1
750 *****************************************************************************/
751extern kal_int8 mmi_chset_get_utf_byte_order(const kal_int8 *str_bom);
752
753/*****************************************************************************
754 * FUNCTION
755 * mmi_chset_utf16_strlen
756 * DESCRIPTION
757 * The function is used for get the number of characters of the given UTF16
758 * encoded string, not including the beginning BOM and the final null
759 * character.
760 * Here we only accept FFFE/FEFF marks as endianness indicators in the
761 * beginning of the stream(See RFC 2781 section 3.2 specifies).
762 * If there is no BOM, the text default is interpreted as big-endian.
763 * The function does not count the surrogate pair. Because of it can't translate
764 * to UCS2.
765 * PARAMETERS
766 * str_utf16 : [IN] UTF-16 encoded string which length is to be computed.
767 * utf16_type : [IN] The type of input UTF-16 encoded string. MMI_CHSET_UTF16LE or MMI_CHSET_UTF16BE
768 * RETURNS
769 * The number of characters of the input UTF16 encoded string.
770 *****************************************************************************/
771extern kal_int32 mmi_chset_utf16_strlen(const kal_int8 *str_utf16, mmi_chset_enum utf16_type);
772
773extern kal_int32 mmi_chset_ucs2_to_utf16_bom_str(
774 kal_uint8 *dest_utf16,
775 kal_int32 dest_size,
776 mmi_chset_enum utf16_type,
777 kal_uint8 *src_ucs2,
778 kal_uint32 *src_end_pos);
779
780/*****************************************************************************
781 * FUNCTION
782 * mmi_chset_guess
783 * DESCRIPTION
784 * Try to guess the charset of string buffer with given guess size.
785 * It will try only the suspect list if suspect_chset_mask is not CHSET_GUESS_ALL.
786 * Otherwise it will guess all the supported chsets.
787 * This function will return the preferred charset if more than one charsets
788 * have the same possibility.
789 * Currently we support: UTF8, UTF16, UCS2, GB2312, BIG5, ISO8859-1
790 * PARAMETERS
791 * buff : [IN] String buffer need to guess the charset
792 * guess_size : [IN] String buffer size in byte used to guess
793 * preferred_chset : [IN] Preferred charset name, pass 0 to use system prefer charset
794 * suspect_chset_mask : [IN] Suspect charsets, use "|" to add more suspect charsets.
795 * Use CHSET_GUESS_ALL to guess in all supported charsets.
796 * RETURNS
797 * Charset Guess result
798 *****************************************************************************/
799extern mmi_chset_enum mmi_chset_guess(
800 const char *buff,
801 kal_int32 guess_size,
802 mmi_chset_enum preferred_chset,
803 kal_uint32 suspect_chset_mask);
804
805/*****************************************************************************
806 * FUNCTION
807 * mmi_chset_set_default_encoding_type
808 * DESCRIPTION
809 * This function is used for set default encoding type (g_chset_text_encoding)
810 * PARAMETERS
811 * chset_name : [IN] Charset name
812 * RETURNS
813 * Default encoding type setting success or fail
814 *****************************************************************************/
815extern kal_bool mmi_chset_set_default_encoding_type(const kal_int8 *chset_name);
816
817/*****************************************************************************
818 * FUNCTION
819 * mmi_chset_set_default_encoding_type
820 * DESCRIPTION
821 * This function is used for set default encoding type (g_chset_text_encoding)
822 * PARAMETERS
823 * chset_id : [IN] Charset ID
824 * RETURNS
825 * Default encoding type setting success or fail
826 *****************************************************************************/
827extern kal_bool mmi_chset_set_default_encoding_type_by_id(mmi_chset_enum chset_id);
828
829/*****************************************************************************
830 * FUNCTION
831 * mmi_chset_get_default_encoding_type
832 * DESCRIPTION
833 * This function is used to get default encoding type (g_chset_text_encoding)
834 * PARAMETERS
835 * NONE
836 * RETURNS
837 * Default encoding id
838 *****************************************************************************/
839extern mmi_chset_enum mmi_chset_get_default_encoding_type(void);
840
841/*****************************************************************************
842 * FUNCTION
843 * mmi_chset_get_chset_list_by_language
844 * DESCRIPTION
845 * Get charset list according to current language
846 * PARAMETERS
847 * chset_list : [OUT] Charset list.
848 * default : [OUT] Default charset.
849 * RETURNS
850 * chset number in the list
851 *****************************************************************************/
852extern kal_int32 mmi_chset_get_chset_list_by_language(mmi_chset_enum *chset_list, mmi_chset_enum *default_chset);
853
854/*****************************************************************************
855 * FUNCTION
856 * mmi_chset_get_enabled_chset_list
857 * DESCRIPTION
858 * Get charset list
859 * PARAMETERS
860 * chset_list : [OUT] Array of charset ids.
861 * RETURNS
862 * Total number of enabled charsets
863 *****************************************************************************/
864extern kal_int32 mmi_chset_get_enabled_chset_list(mmi_chset_enum *chset_list);
865
866/*****************************************************************************
867 * FUNCTION
868 * mmi_chset_get_english_default_chset
869 * DESCRIPTION
870 * Get default charset of English. Dependent of available languages in phone
871 * PARAMETERS
872 * void
873 * RETURNS
874 * default charset
875 *****************************************************************************/
876extern mmi_chset_enum mmi_chset_get_english_default_chset(void);
877
878/*****************************************************************************
879 * FUNCTION
880 * mmi_chset_get_chset_string
881 * DESCRIPTION
882 * Get charset string id (shown in menus) by chset enum
883 * PARAMETERS
884 * chset : [IN] Charset id (enum value)
885 * RETURNS
886 * chset string id
887 *****************************************************************************/
888extern kal_uint16 mmi_chset_get_chset_string(mmi_chset_enum chset);
889
890#ifdef __MMI_CHSET_SJIS__
891extern kal_uint32 mmi_chset_sjis_to_ucs2(
892 kal_uint8 *dest,
893 kal_int32 dest_size,
894 kal_uint8 *src,
895 kal_uint32 *src_end_pos);
896extern kal_uint32 mmi_chset_ucs2_to_sjis(
897 kal_uint8 *dest,
898 kal_int32 dest_size,
899 kal_uint8 *src,
900 kal_uint32 *src_end_pos);
901#endif /* __MMI_CHSET_SJIS__ */
902
903/*****************************************************************************
904 * FUNCTION
905 * mmi_chset_is_enabled
906 * DESCRIPTION
907 * Checks whether chset is enabled or not.
908 * PARAMETERS
909 * chset : [IN] Input charset id
910 * RETURNS
911 * TRUE if enabled
912 *****************************************************************************/
913 extern kal_bool mmi_chset_is_enabled(mmi_chset_enum chset);
914
915/* DOM-NOT_FOR_SDK-BEGIN */
916
917/*****************************************************************************
918 * FUNCTION
919 * mmi_charset_ucs2_to_utf8_length_in_bytes
920 * DESCRIPTION
921 *
922 * PARAMETERS
923 * raw [IN]
924 * RETURNS
925 *
926 *****************************************************************************/
927extern int mmi_charset_ucs2_to_utf8_length_in_bytes(const kal_uint8 *raw);
928
929/* DOM-NOT_FOR_SDK-END */
930
931#endif /* _MMI_CONVERSIONS_H */
932