Logo Search packages:      
Sourcecode: osb-jscore version File versions  Download package

UString KJS::UString::from ( long  l  )  [static]

Constructs a string from a long.

Definition at line 498 of file ustring.cpp.

References UString().

{
  UChar buf[20];
  UChar *end = buf + 20;
  UChar *p = end;
  
  if (l == 0) {
    *--p = '0';
  } else if (l == LONG_MIN) {
    char minBuf[20];
    sprintf(minBuf, "%ld", LONG_MIN);
    return UString(minBuf);
  } else {
    bool negative = false;
    if (l < 0) {
      negative = true;
      l = -l;
    }
    while (l) {
      *--p = (unsigned short)((l % 10) + '0');
      l /= 10;
    }
    if (negative) {
      *--p = '-';
    }
  }
  
  return UString(p, end - p);
}


Generated by  Doxygen 1.6.0   Back to index