Xojo Conferences
XDCMay2019MiamiUSA

encoding some glyphs (Real Studio network user group Mailinglist archive)

Back to the thread list
Previous thread: [LINUX] moviewidth/height and basemoviewidth/height not working
Next thread: Expanding BIN files


FW: Special Valentine's Offer for Valentina - Beat the Price Increase!   -   Lynn Fredricks
  encoding some glyphs   -   Carlo Rubini
   RE: encoding some glyphs   -   RBNUBE
   Re: encoding some glyphs   -   Sven E Olsson
    RE: encoding some glyphs   -   Carlo Rubini
     RE: encoding some glyphs   -   RBNUBE
    Re: encoding some glyphs   -   Carlo Rubini
     Re: encoding some glyphs   -   Tim Jones
    Re: encoding some glyphs   -   Carlo Rubini
     RE: encoding some glyphs   -   RBNUBE
    RE: encoding some glyphs   -   Carlo Rubini
     RE: encoding some glyphs   -   RBNUBE
     RE: encoding some glyphs   -   joe strout.net
     Re: encoding some glyphs   -   John McKernon
      Re: encoding some glyphs   -   joe strout.net
    RE: encoding some glyphs   -   Carlo Rubini
     RE: encoding some glyphs   -   RBNUBE
    RE: encoding some glyphs   -   Carlo Rubini

encoding some glyphs
Date: 04.08.07 06:32 (Sat, 04 Aug 2007 11:32:05 +0600)
From: Carlo Rubini
Hello,

I'm getting some unespected behavior when saving/opening a file
containing some particular glyphs, for instance
α β γ δ (i.e. the Greek glyphs for alpha beta gamma delta).

When I type them into an editfield, they look alright, but when I save
the file

Document.SaveStyledEditField mEditField

and reopen it

item.OpenStyledEditField w.mEditField

the alpha betha gamma delta glyphs show up as question marks.

Am I missing something?

Suggestions welcome. Thanks,

Carlo

RB 5.5.5 Mac OS 10.4.5 (PPC)


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

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

RE: encoding some glyphs
Date: 05.08.07 09:01 (Sun, 5 Aug 2007 04:01:06 -0400)
From: RBNUBE
Playing around with this, I ran into the same thing you did, but only when
saving plain text.

The following seems to work fine:

Dim file as FolderItem

mEditField.Text="I'm getting some unespected behavior when saving/opening
a file containing some particular glyphs, for instance ���‿ (i.e. the
Greek glyphs for alpha beta gamma delta)."

file = DesktopFolder.Child("TEST.txt")
if file <> nil then
file.SaveStyledEditField(mEditField)
end if

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

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

Re: encoding some glyphs
Date: 06.08.07 02:25 (Mon, 6 Aug 2007 03:25:39 +0200)
From: Sven E Olsson
You are missing Text Encoding...

Here is some "Level 1 Encodings Example"
http://www.xhtmlsoftware.com/realbasic.html

Sven E



On 2007-08-04, at 07:32, Carlo Rubini wrote:

> Hello,
>
> I'm getting some unespected behavior when saving/opening a file
> containing some particular glyphs, for instance
> α β γ δ (i.e. the Greek glyphs for alpha beta gamma delta).
>
> When I type them into an editfield, they look alright, but when I save
> the file
>
> Document.SaveStyledEditField mEditField
>
> and reopen it
>
> item.OpenStyledEditField w.mEditField
>
> the alpha betha gamma delta glyphs show up as question marks.
>
> Am I missing something?
>
> Suggestions welcome. Thanks,
>
> Carlo
>
> RB 5.5.5 Mac OS 10.4.5 (PPC)
>
> _______________________________________________
> Unsubscribe or switch delivery mode:
> <http://www.realsoftware.com/support/listmanager/>
> Search the archives:
> <http://support.realsoftware.com/listarchives/lists.html>


Sven E
-----------------------
REALbasic 2007R3 OS X 10.4.10 Intel and 10.3.9/10.4.10 PPC
SEEdit Maxi THE XHTML EDITOR FOR MACINTOSH
http://www.seedit.info


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

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

RE: encoding some glyphs
Date: 06.08.07 01:14 (Mon, 06 Aug 2007 06:14:28 +0600)
From: Carlo Rubini
"RBNUBE" <<email address removed>> wrote:

> Playing around with this, I ran into the same thing you did, but only when
> saving plain text.
>
> The following seems to work fine:
>
> Dim file as FolderItem
>
> mEditField.Text="I'm getting some unespected behavior when saving/opening
> a file containing some particular glyphs, for instance ? ? ? ? (i.e. the
> Greek glyphs for alpha beta gamma delta)."
>
> file = DesktopFolder.Child("TEST.txt")
> if file <> nil then
> file.SaveStyledEditField(mEditField)
> end if

No luck. Even on a new project...

Yet there must be a way; on the list there are people, for instance,
from Sweden: who knows how they deal with THORN and the like?

Thanks for answering,

Carlo
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

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

RE: encoding some glyphs
Date: 06.08.07 02:10 (Sun, 5 Aug 2007 21:10:56 -0400)
From: RBNUBE
> No luck. Even on a new project...
>
> Yet there must be a way; on the list there are people, for instance,
> from Sweden: who knows how they deal with THORN and the like?

This example worked perfectly for me, so my guess is that the reason mine
worked is because I tested on a Windows machine, while you are coding on a
Mac. If I remember correctly, support for RTF is more complete on Windows
than Mac.

You might have better luck trying this with a version of RB that supports
(at least partially) RTF for Mac.

You might also have some luck playing with encodings.



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

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

Re: encoding some glyphs
Date: 07.08.07 04:07 (Tue, 07 Aug 2007 09:07:57 +0600)
From: Carlo Rubini
Danube,
you may be right about the RTF thing, since I'm still sitting on RB 5.5.5

> You are missing Text Encoding...
>
> Here is some "Level 1 Encodings Example"
> http://www.xhtmlsoftware.com/realbasic.html

Sven,
I saw your examples, but I'm dealing with an application containing an
editfield. After writing some text I save it as:

file = DesktopFolder.Child("TEST.txt")
if file <> nil then
file.SaveStyledEditField(mEditField)
end if

When I open this file in the same application via

item.OpenStyledEditField w.mEditField

if the text contained a THORN glyph, I dont get its glyph, but in its
place I get <THORN>.
That's why I wander how you can write/read THORN etc in an editfield.

(All the other usual accented characters and glyphs like dagger etc are
reproduced perfectly).

Thanks, Carlo
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

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

Re: encoding some glyphs
Date: 07.08.07 15:22 (Tue, 7 Aug 2007 07:22:17 -0700)
From: Tim Jones
On Aug 6, 2007, at 8:07 PM, Carlo Rubini wrote:

> Danube,
> you may be right about the RTF thing, since I'm still sitting on RB
> 5.5.5
>
>> You are missing Text Encoding...
>>
>> Here is some "Level 1 Encodings Example"
>> http://www.xhtmlsoftware.com/realbasic.html
>
> Sven,
> I saw your examples, but I'm dealing with an application containing an
> editfield. After writing some text I save it as:
>
> file = DesktopFolder.Child("TEST.txt")

Carlo - what happens if you name the file with .rtf as the extension
instead of .txt? I'm clutching straws here, but that seems to work
best for me when dealing with styled text.

Tim

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

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

Re: encoding some glyphs
Date: 08.08.07 01:06 (Wed, 08 Aug 2007 06:06:27 +0600)
From: Carlo Rubini
> Tim Jones <<email address removed>>

>> > Sven,
>> > I saw your examples, but I'm dealing with an application containing an
>> > editfield. After writing some text I save it as:
>> >
>> > file = DesktopFolder.Child("TEST.txt")
>
> Carlo - what happens if you name the file with .rtf as the extension
> instead of .txt? I'm clutching straws here, but that seems to work
> best for me when dealing with styled text.

No improvement: all the once-so-called high ASCII characters are
reproduced perfectly; other characters (like, for instance, THORN)
inserted thru the Character Palette show up as "?".

Thanks for answering,
Carlo RB 5.5.5 Mac OS 10.4.5

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

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

RE: encoding some glyphs
Date: 08.08.07 01:44 (Tue, 7 Aug 2007 20:44:03 -0400)
From: RBNUBE
Have you tried different encodings yet?

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

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

RE: encoding some glyphs
Date: 08.08.07 04:50 (Wed, 08 Aug 2007 09:50:16 +0600)
From: Carlo Rubini
> From: "RBNUBE" <<email address removed>>
> Have you tried different encodings yet?

Sure: apart from utf-8 (that should not be necessary since an editField
is already utf-8), also macRoman and ISOLatin1, converting/defining both
at saving and opening time.

Using other encodings would not make sense for my app, since I would
have to add encodings for a lot of languages, while I thought that using
a font supporting utf-8 any user around the world would be able to type
any weird glyph in an edit field, save the file as SaveStyledEditField
and open it again with openStyledEditField.

As for extensions, I tried .rtf, .txt and custom ones.

May be things will get solved when (?) I upgrade from 5.5.5

Thanks for answering,
Carlo

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

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

RE: encoding some glyphs
Date: 08.08.07 06:28 (Wed, 8 Aug 2007 01:28:36 -0400)
From: RBNUBE
If it's not too much trouble, download a demo of the newest version and see
how it goes.

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

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

RE: encoding some glyphs
Date: 08.08.07 15:10 (Wed, 8 Aug 2007 08:10:12 -0600)
From: joe strout.net
On Aug 08, 2007, at 03:50 UTC, Carlo Rubini wrote:

> > From: "RBNUBE" <<email address removed>>
> >
> > Have you tried different encodings yet?
>
> Sure: apart from utf-8 (that should not be necessary since an
> editField is already utf-8), also macRoman and ISOLatin1,
> converting/defining both at saving and opening time.

Time for me to jump in and shed what light here I can. The problem
isn't encodings in RB per se; and you have no opportunity in this case
to convert (and certainly shouldn't define) encodings. The basic
problem is that you're not writing a simple text file; you're using
SaveStyledEditField.

The FolderItem.SaveStyledEditField method was added in prehistoric
times, under classic MacOS, where the standard format for styled data
was a SimpleText file -- one with plain WorldScript text in the data
fork, and style info in the resource fork. A very sensible format,
except for the "WorldScript" part. WorldScript was a set of encodings
such as MacRoman, MacJapanese, etc. The only way to know WHICH
encoding a particular run of text was, was to base it on the font
associated with the text. That's a very complex and confusing system,
not nearly as simple as Unicode.

But, if you ask RB to do this, it will do its best for you to convert
the text to WorldScript, and upon reading a WorldScript file (with
OpenStyledEditField), it will attempt to do the reverse. It sounds
like maybe it's not doing it correctly, or perhaps modern versions of
OS X no longer have the right WorldScript encodings associated with the
fonts.

(That's actually my guess -- the StyledEditField code *used* to work,
and I bet that code hasn't been touched in years, and meanwhile Apple
has moved entirely to Unicode, and has a habit of letting old
functionality break -- see 8-bit color support for another example.)

So in short, if it's not working, I doubt there's much you can do about
it. You should stop using SaveAsStyledEditField and
OpenStyledEditField, and instead save your data in some Unicode-based
format such as RTF.

Best,
- Joe

Re: encoding some glyphs
Date: 08.08.07 18:28 (Wed, 08 Aug 2007 13:28:19 -0400)
From: John McKernon
> Sure: apart from utf-8 (that should not be necessary since an editField
> is already utf-8),

Don't count on that - it's possible to paste non-UTF8 text into an edit
field. I always explicitly convert the text retrieved from edit fields to
UTF8.

I wrote a little function to make this easy:

Function MakeUTF8(extends Astr as string) as string
return Astr.ConvertEncoding(Encodings.UTF8)
End Function

To use it when retrieving data from edit fields, I do this:

MyStr=MyEditField.Text

MyStr=MyStr.MakeUTF8

- John

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

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

Re: encoding some glyphs
Date: 08.08.07 18:34 (Wed, 8 Aug 2007 11:34:49 -0600)
From: joe strout.net
On Aug 08, 2007, at 17:28 UTC, John McKernon wrote:

> > Sure: apart from utf-8 (that should not be necessary since an
> editField
> > is already utf-8),
>
> Don't count on that - it's possible to paste non-UTF8 text into an
> edit field.

If by this you mean that REALbasic will automatically convert text in
any other encoding to whatever Unicode format it uses internally in the
EditField, then I agree.

If you mean something else, then I disagree. :)

> I always explicitly convert the text retrieved from edit fields
> to UTF8.

That's harmless, but unnecessary. Text retrieved from an EditField is
always UTF-8 already (at least, on the Mac -- not sure about other
platforms, but I think it's true there too).

On the other hand, if you want to be extra-sure you've got UTF-8, then
converting is a good idea no matter where the text came from -- if it's
already UTF-8, the "conversion" bails out very quickly, so there is
little cost apart from slightly more complex code.

Best,
- Joe

RE: encoding some glyphs
Date: 08.08.07 18:03 (Wed, 08 Aug 2007 23:03:35 +0600)
From: Carlo Rubini
> "RBNUBE" <<email address removed>> said:
>
> If it's not too much trouble, download a demo of the newest version and see
> how it goes.

After what Joe said, I think the matter is pretty settled.

BTW: downloading a demo? I would take ages; my downloading speed has
gone done to 1 Kb/minute.

Thanks again for answering,
Carlo
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

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

RE: encoding some glyphs
Date: 09.08.07 00:59 (Wed, 8 Aug 2007 19:59:03 -0400)
From: RBNUBE
> BTW: downloading a demo? I would take ages; my downloading
> speed has gone done to 1 Kb/minute.

Might be worth a trip to an Internet café, library or a friend with
broadband.

Though, if plain text doesn't bother you, that might be a decent solution.

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

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

RE: encoding some glyphs
Date: 08.08.07 18:03 (Wed, 08 Aug 2007 23:03:56 +0600)
From: Carlo Rubini
> <email address removed> said:

> So in short, if it's not working, I doubt there's much you can do about
> it. You should stop using SaveAsStyledEditField and
> OpenStyledEditField, and instead save your data in some Unicode-based
> format such as RTF.

Cristal crear: Amen.

Thanks, Carlo
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

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