home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / std / internat / 1113 < prev    next >
Encoding:
Text File  |  1993-01-08  |  2.2 KB  |  59 lines

  1. Newsgroups: comp.std.internat
  2. Path: sparky!uunet!haven.umd.edu!decuac!pa.dec.com!decprl!decprl!boyd
  3. From: boyd@prl.dec.com (Boyd Roberts)
  4. Subject: Re: Dumb Americans (was INTERNATIONALIZATION: JAPAN, FAR EAST)
  5. Message-ID: <1993Jan8.092754.6344@prl.dec.com>
  6. Keywords: Han Kanji Katakana Hirugana ISO10646 Unicode Codepages
  7. Sender: news@prl.dec.com (USENET News System)
  8. Nntp-Posting-Host: spooky.prl.dec.com
  9. Organization: Digital Equipment Corporation - Paris Research Laboratory
  10. References: <2615@titccy.cc.titech.ac.jp> <1993Jan5.090747.29232@fcom.cc.utah.edu> <id.EAHW.92A@ferranti.com> <1993Jan7.033153.12133@fcom.cc.utah.edu>
  11. Date: Fri, 8 Jan 1993 09:27:54 GMT
  12. Lines: 45
  13.  
  14. In article <1993Jan7.033153.12133@fcom.cc.utah.edu>, terry@cs.weber.edu (A Wizard of Earth C) writes:
  15. > Consider a newline terminated text database containing fixed length lines,
  16. > or consider a database consisting of variant text records in fixed fields.
  17. > In either case, the amount of data per field is now variant on Runic encoding.
  18. > For instance, if we accept the Plan-9 soloution, an application used in
  19. > both England and the US will vary as to how much data is representable per
  20. > fixed field based on whether or not that data contains the English "#"
  21. > character.  This gets worse the further you get from base ASCII coding.
  22.  
  23. Using Plan 9 utf you know the maximum size in bytes that a Rune can
  24. be encoded into.  Fixed fields only have to be a multiple of this value,
  25. defined to be to be UTFmax.  So where's the problem?
  26.  
  27. We can take this piece of code as working example (ie. functioning)
  28. which takes an array of Runes, encodes them and then calls write
  29. to send them in a reasonably efficient manner (ie 1 Rune != 1 write):
  30.  
  31.     void
  32.     sendrunes(Rune *r, ulong len)
  33.     {
  34.         char    s[128 * UTFmax];
  35.  
  36.         while (len)
  37.         {
  38.             char    *p;
  39.  
  40.             for (p = s; p <= &s[sizeof s - UTFmax] && len; len--)
  41.             {
  42.                  int     n;
  43.  
  44.                  n = runetochar(p, r++);
  45.                  p += n;
  46.             }
  47.  
  48.             (void)write(fd, s, p - s);
  49.         }
  50.      }
  51.  
  52. Runes are your friend.
  53.  
  54.  
  55. Boyd Roberts            boyd@prl.dec.com
  56.  
  57. ``When the going gets wierd, the weird turn pro...''
  58.