]>
git.saurik.com Git - apple/icu.git/blob - icuSources/samples/date/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 *******************************************************************************
18 #include "unicode/ucnv.h"
19 #include "unicode/ustring.h"
23 /* Print a ustring to the specified FILE* in the default codepage */
25 uprint(const UChar
*s
,
30 UConverter
*converter
;
33 const UChar
*mySource
;
34 const UChar
*mySourceEnd
;
40 /* set up the conversion parameters */
41 sourceLen
= u_strlen(s
);
43 mySourceEnd
= mySource
+ sourceLen
;
47 /* open a default converter */
48 converter
= ucnv_open(0, status
);
50 /* if we failed, clean up and exit */
51 if(U_FAILURE(*status
)) goto finish
;
53 /* perform the conversion */
55 /* reset the error code */
56 *status
= U_ZERO_ERROR
;
58 /* perform the conversion */
59 ucnv_fromUnicode(converter
, &myTarget
, myTarget
+ arraySize
,
60 &mySource
, mySourceEnd
, NULL
,
63 /* Write the converted data to the FILE* */
64 fwrite(buf
, sizeof(char), myTarget
- buf
, f
);
66 /* update the conversion parameters*/
70 while(*status
== U_BUFFER_OVERFLOW_ERROR
);
74 /* close the converter */
75 ucnv_close(converter
);