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

char * KJS::UString::ascii (  )  const

Convert the Unicode string to plain ASCII chars chopping of any higher bytes. This method should only be used for *debugging* purposes as it is neither Unicode safe nor free from side effects. In order not to waste any memory the char buffer is static and *shared* by all UString instances.

Definition at line 729 of file ustring.cpp.

References data(), size(), and KJS::UChar::uc.

Referenced by cstring(), KJS::Interpreter::evaluate(), and toDouble().

  // Never make the buffer smaller than normalStatBufferSize.
  // Thus we almost never need to reallocate.
  int length = size();
  int neededSize = length + 1;
  if (neededSize < normalStatBufferSize) {
    neededSize = normalStatBufferSize;
  if (neededSize != statBufferSize) {
    delete [] statBuffer;
    statBuffer = new char [neededSize];
    statBufferSize = neededSize;
  const UChar *p = data();
  char *q = statBuffer;
  const UChar *limit = p + length;
  while (p != limit) {
    *q = p->uc;
  *q = '\0';

  return statBuffer;

Generated by  Doxygen 1.6.0   Back to index