LCOV - code coverage report
Current view: top level - intl/icu/source/common - ustrfmt.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 16 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 1 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : // © 2016 and later: Unicode, Inc. and others.
       2             : // License & terms of use: http://www.unicode.org/copyright.html
       3             : /*
       4             : **********************************************************************
       5             : *   Copyright (C) 2001-2006, International Business Machines
       6             : *   Corporation and others.  All Rights Reserved.
       7             : **********************************************************************
       8             : */
       9             : 
      10             : #include "cstring.h"
      11             : #include "ustrfmt.h"
      12             : 
      13             : 
      14             : /***
      15             :  * Fills in a UChar* string with the radix-based representation of a
      16             :  * uint32_t number padded with zeroes to minwidth.  The result
      17             :  * will be null terminated if there is room.
      18             :  *
      19             :  * @param buffer UChar buffer to receive result
      20             :  * @param capacity capacity of buffer
      21             :  * @param i the unsigned number to be formatted
      22             :  * @param radix the radix from 2..36
      23             :  * @param minwidth the minimum width.  If the result is narrower than
      24             :  *        this, '0's will be added on the left.  Must be <=
      25             :  *        capacity.
      26             :  * @return the length of the result, not including any terminating
      27             :  *        null
      28             :  */
      29             : U_CAPI int32_t U_EXPORT2
      30           0 : uprv_itou (UChar * buffer, int32_t capacity,
      31             :            uint32_t i, uint32_t radix, int32_t minwidth)
      32             : {
      33           0 :     int32_t length = 0;
      34             :     int digit;
      35             :     int32_t j;
      36             :     UChar temp;
      37             : 
      38           0 :     do{
      39           0 :         digit = (int)(i % radix);
      40           0 :         buffer[length++]=(UChar)(digit<=9?(0x0030+digit):(0x0030+digit+7));
      41           0 :         i=i/radix;
      42           0 :     } while(i && length<capacity);
      43             : 
      44           0 :     while (length < minwidth){
      45           0 :         buffer[length++] = (UChar) 0x0030;/*zero padding */
      46             :     }
      47             :     /* null terminate the buffer */
      48           0 :     if(length<capacity){
      49           0 :         buffer[length] = (UChar) 0x0000;
      50             :     }
      51             : 
      52             :     /* Reverses the string */
      53           0 :     for (j = 0; j < (length / 2); j++){
      54           0 :         temp = buffer[(length-1) - j];
      55           0 :         buffer[(length-1) - j] = buffer[j];
      56           0 :         buffer[j] = temp;
      57             :     }
      58           0 :     return length;
      59             : }

Generated by: LCOV version 1.13