staging: csr: remove CsrUint8 typedef
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / staging / csr / csr_unicode.h
CommitLineData
635d2b00
GKH
1#ifndef CSR_UNICODE_H__
2#define CSR_UNICODE_H__
3/*****************************************************************************
4
5 (c) Cambridge Silicon Radio Limited 2010
6 All rights reserved and confidential information of CSR
7
8 Refer to LICENSE.txt included with this source for details
9 on the license terms.
10
11*****************************************************************************/
12
13#include "csr_types.h"
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
19CsrUtf16String *CsrUint32ToUtf16String(CsrUint32 number);
20
21CsrUint32 CsrUtf16StringToUint32(const CsrUtf16String *unicodeString);
22CsrUint32 CsrUtf16StrLen(const CsrUtf16String *unicodeString);
23
24CsrUtf8String *CsrUtf16String2Utf8(const CsrUtf16String *source);
25
26CsrUtf16String *CsrUtf82Utf16String(const CsrUtf8String *utf8String);
27
28CsrUtf16String *CsrUtf16StrCpy(CsrUtf16String *target, const CsrUtf16String *source);
29CsrUtf16String *CsrUtf16StringDuplicate(const CsrUtf16String *source);
30
31CsrUint16 CsrUtf16StrICmp(const CsrUtf16String *string1, const CsrUtf16String *string2);
32CsrUint16 CsrUtf16StrNICmp(const CsrUtf16String *string1, const CsrUtf16String *string2, CsrUint32 count);
33
34CsrUtf16String *CsrUtf16MemCpy(CsrUtf16String *dest, const CsrUtf16String *src, CsrUint32 count);
35CsrUtf16String *CsrUtf16ConcatenateTexts(const CsrUtf16String *inputText1, const CsrUtf16String *inputText2,
36 const CsrUtf16String *inputText3, const CsrUtf16String *inputText4);
37
38CsrUtf16String *CsrUtf16String2XML(CsrUtf16String *str);
39CsrUtf16String *CsrXML2Utf16String(CsrUtf16String *str);
40
41CsrInt32 CsrUtf8StrCmp(const CsrUtf8String *string1, const CsrUtf8String *string2);
42CsrInt32 CsrUtf8StrNCmp(const CsrUtf8String *string1, const CsrUtf8String *string2, CsrSize count);
43CsrUint32 CsrUtf8StringLengthInBytes(const CsrUtf8String *string);
44
45/*******************************************************************************
46
47 NAME
48 CsrUtf8StrTruncate
49
50 DESCRIPTION
51 In-place truncate a string on a UTF-8 character boundary by writing a
52 null character somewhere in the range target[count - 3]:target[count].
53
54 Please note that memory passed must be at least of length count + 1, to
55 ensure space for a full length string that is terminated at
56 target[count], in the event that target[count - 1] is the final byte of
57 a UTF-8 character.
58
59 PARAMETERS
60 target - Target string to truncate.
61 count - The desired length, in bytes, of the resulting string. Depending
62 on the contents, the resulting string length will be between
63 count - 3 and count.
64
65 RETURNS
66 Returns target
67
68*******************************************************************************/
69CsrUtf8String *CsrUtf8StrTruncate(CsrUtf8String *target, CsrSize count);
70
71/*******************************************************************************
72
73 NAME
74 CsrUtf8StrCpy
75
76 DESCRIPTION
77 Copies the null terminated UTF-8 string pointed at by source into the
78 memory pointed at by target, including the terminating null character.
79
80 To avoid overflows, the size of the memory pointed at by target shall be
81 long enough to contain the same UTF-8 string as source (including the
82 terminating null character), and should not overlap in memory with
83 source.
84
85 PARAMETERS
86 target - Pointer to the target memory where the content is to be copied.
87 source - UTF-8 string to be copied.
88
89 RETURNS
90 Returns target
91
92*******************************************************************************/
93CsrUtf8String *CsrUtf8StrCpy(CsrUtf8String *target, const CsrUtf8String *source);
94
95/*******************************************************************************
96
97 NAME
98 CsrUtf8StrNCpy
99
100 DESCRIPTION
101 Copies the first count bytes of source to target. If the end of the
102 source UTF-8 string (which is signaled by a null-character) is found
103 before count bytes have been copied, target is padded with null
104 characters until a total of count bytes have been written to it.
105
106 No null-character is implicitly appended to the end of target, so target
107 will only be null-terminated if the length of the UTF-8 string in source
108 is less than count.
109
110 PARAMETERS
111 target - Pointer to the target memory where the content is to be copied.
112 source - UTF-8 string to be copied.
113 count - Maximum number of bytes to be written to target.
114
115 RETURNS
116 Returns target
117
118*******************************************************************************/
119CsrUtf8String *CsrUtf8StrNCpy(CsrUtf8String *target, const CsrUtf8String *source, CsrSize count);
120
121/*******************************************************************************
122
123 NAME
124 CsrUtf8StrNCpyZero
125
126 DESCRIPTION
127 Equivalent to CsrUtf8StrNCpy, but if the length of source is equal to or
128 greater than count the target string is truncated on a UTF-8 character
129 boundary by writing a null character somewhere in the range
130 target[count - 4]:target[count - 1], leaving the target string
131 unconditionally null terminated in all cases.
132
133 Please note that if the length of source is shorter than count, no
134 truncation will be applied, and the target string will be a one to one
135 copy of source.
136
137 PARAMETERS
138 target - Pointer to the target memory where the content is to be copied.
139 source - UTF-8 string to be copied.
140 count - Maximum number of bytes to be written to target.
141
142 RETURNS
143 Returns target
144
145*******************************************************************************/
146CsrUtf8String *CsrUtf8StrNCpyZero(CsrUtf8String *target, const CsrUtf8String *source, CsrSize count);
147
148/*******************************************************************************
149
150 NAME
151 CsrUtf8StrDup
152
153 DESCRIPTION
154 This function will allocate memory and copy the source string into the
155 allocated memory, which is then returned as a duplicate of the original
156 string. The memory returned must be freed by calling CsrPmemFree when
157 the duplicate is no longer needed.
158
159 PARAMETERS
160 source - UTF-8 string to be duplicated.
161
162 RETURNS
163 Returns a duplicate of source.
164
165*******************************************************************************/
166CsrUtf8String *CsrUtf8StrDup(const CsrUtf8String *source);
167
168CsrUtf8String *CsrUtf8StringConcatenateTexts(const CsrUtf8String *inputText1, const CsrUtf8String *inputText2, const CsrUtf8String *inputText3, const CsrUtf8String *inputText4);
169
170/*
171 * UCS2
172 *
173 * D-13157
174 */
7e6f5794 175typedef u8 CsrUcs2String;
635d2b00
GKH
176
177CsrSize CsrUcs2ByteStrLen(const CsrUcs2String *ucs2String);
178CsrSize CsrConverterUcs2ByteStrLen(const CsrUcs2String *str);
179
7e6f5794
GKH
180u8 *CsrUcs2ByteString2Utf8(const CsrUcs2String *ucs2String);
181CsrUcs2String *CsrUtf82Ucs2ByteString(const u8 *utf8String);
635d2b00 182
7e6f5794
GKH
183u8 *CsrUtf16String2Ucs2ByteString(const CsrUtf16String *source);
184CsrUtf16String *CsrUcs2ByteString2Utf16String(const u8 *source);
635d2b00
GKH
185
186#ifdef __cplusplus
187}
188#endif
189
190#endif