]>
git.saurik.com Git - apple/icu.git/blob - icuSources/samples/date/uprint.c
2 ***********************************************************************
3 * © 2016 and later: Unicode, Inc. and others.
4 * License & terms of use: http://www.unicode.org/copyright.html#License
5 ***********************************************************************
6 **********************************************************************
7 * Copyright (C) 1998-2001, International Business Machines Corporation
8 * and others. All Rights Reserved.
9 **********************************************************************
13 * Modification History:
15 * Date Name Description
16 * 06/14/99 stephen Creation.
17 *******************************************************************************
22 #include "unicode/ucnv.h"
23 #include "unicode/ustring.h"
27 /* Print a ustring to the specified FILE* in the default codepage */
29 uprint(const UChar
*s
,
34 UConverter
*converter
;
37 const UChar
*mySource
;
38 const UChar
*mySourceEnd
;
44 /* set up the conversion parameters */
45 sourceLen
= u_strlen(s
);
47 mySourceEnd
= mySource
+ sourceLen
;
51 /* open a default converter */
52 converter
= ucnv_open(0, status
);
54 /* if we failed, clean up and exit */
55 if(U_FAILURE(*status
)) goto finish
;
57 /* perform the conversion */
59 /* reset the error code */
60 *status
= U_ZERO_ERROR
;
62 /* perform the conversion */
63 ucnv_fromUnicode(converter
, &myTarget
, myTarget
+ arraySize
,
64 &mySource
, mySourceEnd
, NULL
,
67 /* Write the converted data to the FILE* */
68 fwrite(buf
, sizeof(char), myTarget
- buf
, f
);
70 /* update the conversion parameters*/
74 while(*status
== U_BUFFER_OVERFLOW_ERROR
);
78 /* close the converter */
79 ucnv_close(converter
);