blob: 7487e9b084f26ac4d4e644d050a5a0385561dbfa [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
2 * Copyright (C) 2007 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17
18#ifndef __DRM_I18N_H__
19#define __DRM_I18N_H__
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25#include <drm_common_types.h>
26
27/**
28 * @name Charset value defines
29 * @ingroup i18n
30 *
31 * Charset value defines
32 * see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/intl/unicode_81rn.asp
33 */
34typedef enum {
35 DRM_CHARSET_GBK = 936, /** Simplified Chinese GBK (CP936) */
36 DRM_CHARSET_GB2312 = 20936, /** Simplified Chinese GB2312 (CP936) */
37 DRM_CHARSET_BIG5 = 950, /** BIG5 (CP950) */
38 DRM_CHARSET_LATIN1 = 28591, /** ISO 8859-1, Latin 1 */
39 DRM_CHARSET_LATIN2 = 28592, /** ISO 8859-2, Latin 2 */
40 DRM_CHARSET_LATIN3 = 28593, /** ISO 8859-3, Latin 3 */
41 DRM_CHARSET_LATIN4 = 28594, /** ISO 8859-4, Latin 4 */
42 DRM_CHARSET_CYRILLIC = 28595, /** ISO 8859-5, Cyrillic */
43 DRM_CHARSET_ARABIC = 28596, /** ISO 8859-6, Arabic */
44 DRM_CHARSET_GREEK = 28597, /** ISO 8859-7, Greek */
45 DRM_CHARSET_HEBREW = 28598, /** ISO 8859-8, Hebrew */
46 DRM_CHARSET_LATIN5 = 28599, /** ISO 8859-9, Latin 5 */
47 DRM_CHARSET_LATIN6 = 865, /** ISO 8859-10, Latin 6 (not sure here) */
48 DRM_CHARSET_THAI = 874, /** ISO 8859-11, Thai */
49 DRM_CHARSET_LATIN7 = 1257, /** ISO 8859-13, Latin 7 (not sure here) */
50 DRM_CHARSET_LATIN8 = 38598, /** ISO 8859-14, Latin 8 (not sure here) */
51 DRM_CHARSET_LATIN9 = 28605, /** ISO 8859-15, Latin 9 */
52 DRM_CHARSET_LATIN10 = 28606, /** ISO 8859-16, Latin 10 */
53 DRM_CHARSET_UTF8 = 65001, /** UTF-8 */
54 DRM_CHARSET_UTF16LE = 1200, /** UTF-16 LE */
55 DRM_CHARSET_UTF16BE = 1201, /** UTF-16 BE */
56 DRM_CHARSET_HINDI = 57002, /** Hindi/Mac Devanagari */
57 DRM_CHARSET_UNSUPPORTED = -1
58} DRM_Charset_t;
59
60/**
61 * Convert multibyte string of specified charset to unicode string.
62 * Note NO terminating '\0' will be appended to the output unicode string.
63 *
64 * @param charset Charset of the multibyte string.
65 * @param mbs Multibyte string to be converted.
66 * @param mbsLen Number of the bytes (in mbs) to be converted.
67 * @param wcsBuf Buffer for the converted unicode characters.
68 * If wcsBuf is NULL, the function returns the number of unicode
69 * characters required for the buffer.
70 * @param bufSizeInWideChar The size (in wide char) of wcsBuf
71 * @param bytesConsumed The number of bytes in mbs that have been successfully
72 * converted. The value of *bytesConsumed is undefined
73 * if wcsBuf is NULL.
74 *
75 * @return Number of the successfully converted unicode characters if wcsBuf
76 * is not NULL. If wcsBuf is NULL, returns required unicode buffer
77 * size. -1 for unrecoverable errors.
78 */
79int32_t DRM_i18n_mbsToWcs(DRM_Charset_t charset,
80 const uint8_t *mbs, int32_t mbsLen,
81 uint16_t *wcsBuf, int32_t bufSizeInWideChar,
82 int32_t *bytesConsumed);
83
84/**
85 * Convert unicode string to multibyte string with specified charset.
86 * Note NO terminating '\0' will be appended to the output multibyte string.
87 *
88 * @param charset Charset of the multibyte string to be converted to.
89 * @param wcs Unicode string to be converted.
90 * @param wcsLen Number of the unicode characters (in wcs) to be converted.
91 * @param mbsBuf Buffer for converted multibyte characters.
92 * If mbsBuf is NULL, the function returns the number of bytes
93 * required for the buffer.
94 * @param bufSizeInByte The size (in byte) of mbsBuf.
95 *
96 * @return Number of the successfully converted bytes.
97 */
98int32_t DRM_i18n_wcsToMbs(DRM_Charset_t charset,
99 const uint16_t *wcs, int32_t wcsLen,
100 uint8_t *mbsBuf, int32_t bufSizeInByte);
101
102#ifdef __cplusplus
103}
104#endif
105
106#endif
107