]>
git.saurik.com Git - apple/icu.git/blob - icuSources/samples/cal/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 *******************************************************************************
21 #include "unicode/ucnv.h"
22 #include "unicode/ustring.h"
26 /* Print a ustring to the specified FILE* in the default codepage */
28 uprint(const UChar
*s
,
33 UConverter
*converter
;
36 const UChar
*mySource
;
37 const UChar
*mySourceEnd
;
43 /* set up the conversion parameters */
44 sourceLen
= u_strlen(s
);
46 mySourceEnd
= mySource
+ sourceLen
;
50 /* open a default converter */
51 converter
= ucnv_open(0, status
);
53 /* if we failed, clean up and exit */
54 if(U_FAILURE(*status
)) goto finish
;
56 /* perform the conversion */
58 /* reset the error code */
59 *status
= U_ZERO_ERROR
;
61 /* perform the conversion */
62 ucnv_fromUnicode(converter
, &myTarget
, myTarget
+ arraySize
,
63 &mySource
, mySourceEnd
, NULL
,
66 /* Write the converted data to the FILE* */
67 fwrite(buf
, sizeof(char), myTarget
- buf
, f
);
69 /* update the conversion parameters*/
73 while(*status
== U_BUFFER_OVERFLOW_ERROR
);
77 /* close the converter */
78 ucnv_close(converter
);