realbasic-nug
[Top] [All Lists]

Re: WritePString weirdness...

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: WritePString weirdness...
From: Joe Huber <joehuber at talasoft dot com>
Date: Sun, 30 Mar 2008 13:22:16 -0700
Delivered-to: listarchive at realsoftware dot com
Delivered-to: realbasic-nug at lists dot realsoftware dot com
References: <226027DE-9E67-4701-90AD-12E8F3383CF6 at rbclass dot com> <A652AB13-FCF7-4D95-B6B1-5EC6EC3E84DE at inspiringapps dot com> <3E14F3DA-1A0F-47A7-A23A-5561C8EFDFC3 at rbclass dot com> <A0720DC7-6E68-4825-B1E7-06FA772B07E7 at inspiringapps dot com> <A08DAFF0-4131-4C31-BE88-965126CC576F at rbclass dot com> <09004169-C758-401C-BF6E-6FB615336097 at rbclass dot com> <1BD9DBC6-83AA-42FF-912E-010229927261 at sentman dot com> <7FAFCF2F-6532-42EC-B2DD-F1151D4F8627 at inspiringapps dot com> <58BF1847-25A7-4E65-8114-FB91CF483883 at sentman dot com> <52D0AB44-85E7-447B-AC5F-9ABFFAB3B6AA at inspiringapps dot com>
>On Leopard Apple forced all strings in AppleScripts to UTF16

Yes, I discovered that too. And it brought to light two areas 
(listboxes and DrawString) where RB doesn't handle UTF16 text 
correctly and displays garbled text instead. The workaround is to 
convert strings to UTF8 before inserting into a listbox or using 
DrawString.

UTF16 strings display incorrectly in Listbox and DrawString
http://www.realsoftware.com/feedback/viewreport.php?reportid=avxgeexz


RB doesn't handle UTF16 encoded text properly and displays garbage in 
two scenarios:
- DrawString of UTF16 encoded text
- When listbox text is UTF16 encoded and is too wide to fit within the cell

UTF8 encoded text works OK in both scenarios

Try code similar to this. The string returned from ConvertEncoding is 
correct in both cases, but RB displays them incorrectly.

  dim theEncoding as TextEncoding
  if RadioButton1.Value then
    theEncoding = Encodings.UTF8
  else
    theEncoding = Encodings.UTF16
  end if

  dim g as Graphics = Canvas1.Graphics
  g.ClearRect 0, 0, g.width, g.Height
  g.DrawString ConvertEncoding("The quick brown fox jumps over the 
lazy dog.", theEncoding), 0, 20

  Listbox1.DeleteAllRows
  dim s as string
  for i as integer = 1 to 10
    s = s + "Text"
    Listbox1.AddRow ConvertEncoding (s, theEncoding)
  next
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>


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