gettingstarted
[Top] [All Lists]

more on Chr (was Re: Getting Started Digest #111)

To: "Getting Started" <gettingstarted at lists dot realsoftware dot com>
Subject: more on Chr (was Re: Getting Started Digest #111)
From: "Joseph J. Strout" <joe at realsoftware dot com>
Date: Mon, 24 Nov 2003 10:16:35 -0600
References: <EEF1E293-1E97-11D8-BB6F-0003938E4448 at frontiernet dot net>
At 10:04 AM -0600 11/24/03, Harrie Westphal wrote:

Writing the code exactly as you have it above I got the same gibberish in the editfield that you showed above. However, if I change the code as follows the editfield looks fine in the end, one character per line as and the character you would expect.

for x=164 to 169
  s=s+chr(x)+chr(13)
next
me.text=s

Note that this is still incorrect, because you're still calling Chr() with values above 127.

Seems like something with the editfield isn't working exactly right when you keep appending to it as in your original example.

It's working fine, given the nonsensical data it was fed. The difference in the two cases has to do with when you force RB to guess what you mean by these undefined characters. A better solution is to not make it guess. The loop could be written:

  for x = 164 to 169
me.selText = str(x) + " in MacRoman: " + Encodings.MacRoman.Chr(x) + EndOfLine
    me.selText = str(x) + " in Unicode: " + Encodings.UTF8.Chr(x) + EndOfLine
  next

which will also let you compare MacRoman and Unicode for this range of code points.

Best,
- Joe

--
,------------------------------------------------------------------.
|    Joseph J. Strout           REAL Software, Inc.                |
|    joe at realsoftware dot com       http://www.realsoftware.com        |
`------------------------------------------------------------------'

- - -
Unsubscribe or switch delivery mode:
<http://support.realsoftware.com/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

<Prev in Thread] Current Thread [Next in Thread>