other languages.

If I have an application that must be able to handle other languages other than english.
I assume there must be a build option that selects the language and character set of the build.
How is this done in Xojo?

If I have a label on the GUI I assume I shouldn’t hard code the text in the IDE… but rather use something like #App.ProvinceLabel

There must be some thing like
IF DEFS Language = English then
#App.ProveninceLable = “Quebec”
Else if Language = French then
#App.ProvinceLabel = “Qubec”
end if

Also at some point I may open a Chinese file and need to set my text area character set…

Look up “dynamic” constants in the user manual.

Thanks Kem…

#App.Province.
Platform  Language  Value
Any           English       Quebec
Any           French        Qubec
Any           Default        Kwebec

So that works well…
but now how do I tell the text input fields that they should interpret the data in text as say Korean? Given that as far as I know the character set for Korean is ISO-IR 149

Unicode has all those characters, no? You shouldn’t have to worry about it.

It may well be able to render the language… but does that mean that my ISO-IR 149 character stream can just be written directly without and translation to unicode?

Text fields automatically convert to UTF-8. Don’t overthink this.

Technically, TextFields read the encoded text to display characters. They return their contents encoded as UTF-8.

It’s a common misconception that the text is somehow tied to the encoding. It’s not, anymore than your Great American Novel is tied to a word processor.

I would suggest watching this video. You are in for a world of hard work and heartbreak…

Internationalizing Code

This string of bytes is a persons name in korean.

&h1B,&h24,&h29,&h43,&hB1,&hE8,&hC8,&hF1,&hC1,&hDF,&h1B,&h28,&h42,&h20

I’d like just to be able to set a label such that it displays properly…
I’ll try … and thanks for the tutorial links… I will watch them tonight.

[quote=209575:@Brian O’Brien]This string of bytes is a persons name in korean.

&h1B,&h24,&h29,&h43,&hB1,&hE8,&hC8,&hF1,&hC1,&hDF,&h1B,&h28,&h42,&h20

I’d like just to be able to set a label such that it displays properly…
I’ll try … and thanks for the tutorial links… I will watch them tonight.[/quote]

This does not look right. Here is what I get turning these bytes into UTF-16
???

dim s as string = &u1B+&u24+&u29+&u43+&uB1+&uE8+&uC8+&uF1+&uC1+&uDF+&u1B+&u28+&u42+&u20 dim MyMemoryBlock as new memoryblock(14) MyMemoryBlock = s TextField1.text=DefineEncoding(MyMemoryBlock.StringValue(0,14), Encodings.UTF16 )

Rather than bytes, you should simply request a file.

The first byte is ESC, and the last one Chr(13), both not printable characters.

[code]
//&h1B,&h24,&h29,&h43,&hB1,&hE8,&hC8,&hF1,&hC1,&hDF,&h1B,&h28,&h42,&h20

dim myMemoryBlock as new MemoryBlock(13)

myMemoryBlock.UInt8Value(0) = &h1B
myMemoryBlock.UInt8Value(1) = &h24
myMemoryBlock.UInt8Value(2) = &h29
myMemoryBlock.UInt8Value(3) = &h43
myMemoryBlock.UInt8Value(4) = &hB1
myMemoryBlock.UInt8Value(5) = &hE8
myMemoryBlock.UInt8Value(6) = &hC8
myMemoryBlock.UInt8Value(7) = &hF1
myMemoryBlock.UInt8Value(8) = &hC1
myMemoryBlock.UInt8Value(9) = &hDF
myMemoryBlock.UInt8Value(10) = &h1B
myMemoryBlock.UInt8Value(11) = &h28
myMemoryBlock.UInt8Value(12) = &h42
//myMemoryBlock.UInt8Value(13) = &h20

Label1.text=DefineEncoding(MyMemoryBlock.StringValue(0,13), Encodings.macKorean )[/code]

Almost looks correct but for some reason there are a few characters before and after that I do not know why they appear.
Not sure where the $)C ??? (B
??? Is all I should see.

I mean I do see that the bytes exist in the binary data… I’m just not sure why they are there, it may be that I should use a different encoding? (ISO 2022 IR 149)

[quote=209581:@Brian O’Brien] //&h1B,&h24,&h29,&h43,&hB1,&hE8,&hC8,&hF1,&hC1,&hDF,&h1B,&h28,&h42,&h20[/quote]

Ask for a file. With the current systems, you should never have to go through that kind of middle age, antiquated manipulations.

Tons of engineers have done miracles for inter systems transparent compatibility, so for instance a file created on Windows in Korean opens on an English Mac without having to do anything special. Going back to bytes without even knowing the encoding is plain ridiculous.

Of course not… I have a medical image and have to cut out the relevant binary data from the file for the purpose of this question.

Because it depends what encoding the name was in before being turned into bytes
If it was UTF-8 then you get one set of bytes
If it was ISO-8859 something you get different bytes
If it what one of the korean encodings you get different bytes

You have to know what encoding those bytes came from to know how to reconstitute it and display them

Good luck. Without even a graphic representation of what you should expect, you are in for plenty of pleasure…

Michel… [quote]??? Is all I should see.[/quote]
As I said.

[quote=209587:@Norman Palardy]Because it depends what encoding the name was in before being turned into bytes
You have to know what encoding those bytes came from to know how to reconstitute it and display them[/quote]
The encoding is (ISO 2022 IR 149)

[quote=209595:@Brian O’Brien]Michel…
??? Is all I should see.
As I said.[/quote]

Congratulations ! You got a perfectly fine Korean word.

If it was for me, I would simply paste that into a constant and use it without bothering about encodings and bytes. As I said, engineers have worked very hard for that process to be easy. Just take advantage of it.

I just tested placing that in a constant and displaying it in a label, in a MsgBox and in System.Debuglog ; displays quite fine with System font.

If you need to save that on disk, I believe you can use a TextArea.StyledText.RTFData not to lose formatting and encoding upon reload.

But is MacKorean = ISO 2022 IR 149 ?
I’m not sure it is
If not then any thing after define encoding will interpret the bytes incorrectly
And I’m not sure there IS one of the known encodings that is ISO 2022 IR 149

EDIT : doesn’t look like MacKorean IS 2022 IR 149 its EUR-KC
But cp949 from ms might be
And it’s not one of the encodings listed

You might have to manually translate some of this if its not a known encoding

And some of the other “cruft” you see is from the data and not using the matching encoding

[code]dim myMemoryBlock as new MemoryBlock(13)

myMemoryBlock.UInt8Value(0) = &h1B // ESC
myMemoryBlock.UInt8Value(1) = &h24 // $
myMemoryBlock.UInt8Value(2) = &h29 // )
myMemoryBlock.UInt8Value(3) = &h43 // C
myMemoryBlock.UInt8Value(4) = &hB1 // DBCS lead marker
myMemoryBlock.UInt8Value(5) = &hE8
myMemoryBlock.UInt8Value(6) = &hC8
myMemoryBlock.UInt8Value(7) = &hF1
myMemoryBlock.UInt8Value(8) = &hC1
myMemoryBlock.UInt8Value(9) = &hDF
myMemoryBlock.UInt8Value(10) = &h1B
myMemoryBlock.UInt8Value(11) = &h28 // (
myMemoryBlock.UInt8Value(12) = &h42 // B
//myMemoryBlock.UInt8Value(13) = &h20 // space[/code]

This must be a DICOM image if its using ISO 2022 IR 149

Mike … You’re missing the point… the point is to be able read a binary stream or memory block from a binary file and extract information and write it to a user interface element. If my issue were as simple as cutting and pasting i would not have achieved this post in the first place as that is what i did to illustrate the issue. :wink: :slight_smile:

Norman. I think you are on to something, I’m wondering if this is a standard escape sequence that is used to select quadrants of the encoding.
Reading this there is a table that has that exact escape sequence it it…

https://en.wikipedia.org/wiki/ISO/IEC_2022

If I’m understanding this wiki page these escape sequences should be part of the datastream to dictate what portion of the table the following byte refer to.