2 ******************************************************************************
4 * Copyright (C) 1999-2004, International Business Machines
5 * Corporation and others. All Rights Reserved.
7 ******************************************************************************
10 * Implements all the low level conversion functions
11 * T_UnicodeConverter_{to,from}Unicode_$ConversionType
15 * 06/29/2000 helena Major rewrite of the callback APIs.
18 #include "unicode/utypes.h"
20 #if !UCONFIG_NO_CONVERSION
22 #include "unicode/ucnv_err.h"
23 #include "unicode/ucnv.h"
24 #include "unicode/uset.h"
30 ucnv_getCompleteUnicodeSet(const UConverter
*cnv
,
32 UConverterUnicodeSet which
,
33 UErrorCode
*pErrorCode
) {
34 sa
->addRange(sa
->set
, 0, 0x10ffff);
38 ucnv_getNonSurrogateUnicodeSet(const UConverter
*cnv
,
40 UConverterUnicodeSet which
,
41 UErrorCode
*pErrorCode
) {
42 sa
->addRange(sa
->set
, 0, 0xd7ff);
43 sa
->addRange(sa
->set
, 0xe000, 0x10ffff);
47 ucnv_fromUWriteBytes(UConverter
*cnv
,
48 const char *bytes
, int32_t length
,
49 char **target
, const char *targetLimit
,
52 UErrorCode
*pErrorCode
) {
57 if(offsets
==NULL
|| (o
=*offsets
)==NULL
) {
58 while(length
>0 && t
<targetLimit
) {
63 /* output with offsets */
64 while(length
>0 && t
<targetLimit
) {
76 t
=(char *)cnv
->charErrorBuffer
;
77 cnv
->charErrorBufferLength
=(int8_t)length
;
79 *t
++=(uint8_t)*bytes
++;
82 *pErrorCode
=U_BUFFER_OVERFLOW_ERROR
;
87 ucnv_toUWriteUChars(UConverter
*cnv
,
88 const UChar
*uchars
, int32_t length
,
89 UChar
**target
, const UChar
*targetLimit
,
92 UErrorCode
*pErrorCode
) {
97 if(offsets
==NULL
|| (o
=*offsets
)==NULL
) {
98 while(length
>0 && t
<targetLimit
) {
103 /* output with offsets */
104 while(length
>0 && t
<targetLimit
) {
116 t
=cnv
->UCharErrorBuffer
;
117 cnv
->UCharErrorBufferLength
=(int8_t)length
;
122 *pErrorCode
=U_BUFFER_OVERFLOW_ERROR
;
127 ucnv_toUWriteCodePoint(UConverter
*cnv
,
129 UChar
**target
, const UChar
*targetLimit
,
132 UErrorCode
*pErrorCode
) {
142 } else /* c is a supplementary code point */ {
152 if(offsets
!=NULL
&& (o
=*offsets
)!=NULL
) {
163 /* write overflow from c */
167 U16_APPEND_UNSAFE(cnv
->UCharErrorBuffer
, i
, c
);
168 cnv
->UCharErrorBufferLength
=i
;
170 *pErrorCode
=U_BUFFER_OVERFLOW_ERROR
;