Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(369)

Side by Side Diff: icu46/source/common/ustrfmt.c

Issue 5516007: Check in the pristine copy of ICU 4.6... (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/
Patch Set: Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « icu46/source/common/ustrfmt.h ('k') | icu46/source/common/ustring.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 /*
2 **********************************************************************
3 * Copyright (C) 2001-2006, International Business Machines
4 * Corporation and others. All Rights Reserved.
5 **********************************************************************
6 */
7
8 #include "cstring.h"
9 #include "ustrfmt.h"
10
11
12 /***
13 * Fills in a UChar* string with the radix-based representation of a
14 * uint32_t number padded with zeroes to minwidth. The result
15 * will be null terminated if there is room.
16 *
17 * @param buffer UChar buffer to receive result
18 * @param capacity capacity of buffer
19 * @param i the unsigned number to be formatted
20 * @param radix the radix from 2..36
21 * @param minwidth the minimum width. If the result is narrower than
22 * this, '0's will be added on the left. Must be <=
23 * capacity.
24 * @return the length of the result, not including any terminating
25 * null
26 */
27 U_CAPI int32_t U_EXPORT2
28 uprv_itou (UChar * buffer, int32_t capacity,
29 uint32_t i, uint32_t radix, int32_t minwidth)
30 {
31 int32_t length = 0;
32 int digit;
33 int32_t j;
34 UChar temp;
35
36 do{
37 digit = (int)(i % radix);
38 buffer[length++]=(UChar)(digit<=9?(0x0030+digit):(0x0030+digit+7));
39 i=i/radix;
40 } while(i && length<capacity);
41
42 while (length < minwidth){
43 buffer[length++] = (UChar) 0x0030;/*zero padding */
44 }
45 /* null terminate the buffer */
46 if(length<capacity){
47 buffer[length] = (UChar) 0x0000;
48 }
49
50 /* Reverses the string */
51 for (j = 0; j < (length / 2); j++){
52 temp = buffer[(length-1) - j];
53 buffer[(length-1) - j] = buffer[j];
54 buffer[j] = temp;
55 }
56 return length;
57 }
OLDNEW
« no previous file with comments | « icu46/source/common/ustrfmt.h ('k') | icu46/source/common/ustring.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698