]>
git.saurik.com Git - apple/icu.git/blob - icuSources/samples/cal/uprint.c
2 **********************************************************************
3 * Copyright (C) 1998-2001, International Business Machines Corporation
4 * and others. All Rights Reserved.
5 **********************************************************************
9 * Modification History:
11 * Date Name Description
12 * 06/14/99 stephen Creation.
13 *******************************************************************************
17 #include "unicode/ucnv.h"
18 #include "unicode/ustring.h"
22 /* Print a ustring to the specified FILE* in the default codepage */
24 uprint(const UChar
*s
,
29 UConverter
*converter
;
32 const UChar
*mySource
;
33 const UChar
*mySourceEnd
;
39 /* set up the conversion parameters */
40 sourceLen
= u_strlen(s
);
42 mySourceEnd
= mySource
+ sourceLen
;
46 /* open a default converter */
47 converter
= ucnv_open(0, status
);
49 /* if we failed, clean up and exit */
50 if(U_FAILURE(*status
)) goto finish
;
52 /* perform the conversion */
54 /* reset the error code */
55 *status
= U_ZERO_ERROR
;
57 /* perform the conversion */
58 ucnv_fromUnicode(converter
, &myTarget
, myTarget
+ arraySize
,
59 &mySource
, mySourceEnd
, NULL
,
62 /* Write the converted data to the FILE* */
63 fwrite(buf
, sizeof(char), myTarget
- buf
, f
);
65 /* update the conversion parameters*/
69 while(*status
== U_BUFFER_OVERFLOW_ERROR
);
73 /* close the converter */
74 ucnv_close(converter
);