1 // Copyright (C) 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
4 ******************************************************************************
6 * Copyright (C) 1999-2004, International Business Machines
7 * Corporation and others. All Rights Reserved.
9 ******************************************************************************
12 * Implements all the low level conversion functions
13 * T_UnicodeConverter_{to,from}Unicode_$ConversionType
17 * 06/29/2000 helena Major rewrite of the callback APIs.
20 #include "unicode/utypes.h"
22 #if !UCONFIG_NO_CONVERSION
24 #include "unicode/ucnv_err.h"
25 #include "unicode/ucnv.h"
26 #include "unicode/uset.h"
32 ucnv_getCompleteUnicodeSet(const UConverter *cnv,
34 UConverterUnicodeSet which,
35 UErrorCode *pErrorCode) {
36 sa->addRange(sa->set, 0, 0x10ffff);
40 ucnv_getNonSurrogateUnicodeSet(const UConverter *cnv,
42 UConverterUnicodeSet which,
43 UErrorCode *pErrorCode) {
44 sa->addRange(sa->set, 0, 0xd7ff);
45 sa->addRange(sa->set, 0xe000, 0x10ffff);
49 ucnv_fromUWriteBytes(UConverter *cnv,
50 const char *bytes, int32_t length,
51 char **target, const char *targetLimit,
54 UErrorCode *pErrorCode) {
59 if(offsets==NULL || (o=*offsets)==NULL) {
60 while(length>0 && t<targetLimit) {
65 /* output with offsets */
66 while(length>0 && t<targetLimit) {
78 t=(char *)cnv->charErrorBuffer;
79 cnv->charErrorBufferLength=(int8_t)length;
81 *t++=(uint8_t)*bytes++;
84 *pErrorCode=U_BUFFER_OVERFLOW_ERROR;
89 ucnv_toUWriteUChars(UConverter *cnv,
90 const UChar *uchars, int32_t length,
91 UChar **target, const UChar *targetLimit,
94 UErrorCode *pErrorCode) {
99 if(offsets==NULL || (o=*offsets)==NULL) {
100 while(length>0 && t<targetLimit) {
105 /* output with offsets */
106 while(length>0 && t<targetLimit) {
118 t=cnv->UCharErrorBuffer;
119 cnv->UCharErrorBufferLength=(int8_t)length;
124 *pErrorCode=U_BUFFER_OVERFLOW_ERROR;
129 ucnv_toUWriteCodePoint(UConverter *cnv,
131 UChar **target, const UChar *targetLimit,
134 UErrorCode *pErrorCode) {
144 } else /* c is a supplementary code point */ {
154 if(offsets!=NULL && (o=*offsets)!=NULL) {
165 /* write overflow from c */
169 U16_APPEND_UNSAFE(cnv->UCharErrorBuffer, i, c);
170 cnv->UCharErrorBufferLength=i;
172 *pErrorCode=U_BUFFER_OVERFLOW_ERROR;