NetTalk Central

Author Topic: Spanish and utf-8 charset problem  (Read 4108 times)

Alberto

  • Hero Member
  • *****
  • Posts: 1873
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
Spanish and utf-8 charset problem
« on: July 11, 2021, 07:15:08 AM »
Hi, NT11.48

Trying to display:
Configuraci?nxxx (Ive added some xxx to the end to see the efect)
You are seeing a ? instead of my char I dont know why, in the 1rts pic you can see the real char.

Setting the Webserver charset to st:CP_WINDOWS_1250, it works ok
Setting the Webserver charset to 'utf-8' and converting the string to utf-8 using

Code: [Select]
   
            st.SetValue('Configuraci?nxxx')
            st.tounicode(st:EncodeUtf8,st:CP_WINDOWS_1250)
            Return self._jsok(clip(strad.GetValue()))

It does not work.
As you can see in the pic the result is a xtrange char and less characters, and the xxx are not there.

How to solve this? what am I doing wrong?
Thanks
« Last Edit: July 12, 2021, 05:13:09 AM by michelis »
-----------
Regards
Alberto

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Spanish and utf-8 charset problem
« Reply #1 on: July 13, 2021, 07:56:25 PM »
Your site should be set to utf-8.

What is your "Save Data as" set to?

Is this word coming out the database, or is it in some template setting, or embed code or somewhere?

Cheers
Bruce

Alberto

  • Hero Member
  • *****
  • Posts: 1873
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
Re: Spanish and utf-8 charset problem
« Reply #2 on: July 14, 2021, 05:14:24 AM »
Your site should be set to utf-8.
It is.

What is your "Save Data as" set to?
No matter, Ive tried saving as Spanish and utf-8 and same result

Is this word coming out the database, or is it in some template setting, or embed code or somewhere?
This is readed from a translate file, just a .txt ascii file.

Here you have your BasicBrowseAndForm (1) example modified to read Paqueteria.TRN to translate "Mailboxes" to "Configuraci?n", all in utf-8 and getting:
"ConfiguraciĂłn"
The .trn is read in Global Embeds to a queue.
The Translate Method converts the translation to utf8 using st.

Could not attached this here so, this is the dropbox link:
https://www.dropbox.com/s/8ioz5yno70b6tmb/BasicBrowseAndForm.zip?dl=0

Thanks





« Last Edit: July 14, 2021, 05:58:11 AM by michelis »
-----------
Regards
Alberto

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Spanish and utf-8 charset problem
« Reply #3 on: July 14, 2021, 10:16:32 PM »
>> >> What is your "Save Data as" set to?
>> No matter, Ive tried saving as Spanish and utf-8 and same result

so, yeah this setting does matter, and it's important you set it correctly depending on what you are doing.
In other words you can't just switch it between values, and it's not a setting to "play" with - it needs to match what is in your database.

So set it correctly, and then let me know what it is set to. Because the rest of the answer will change depending on what this should be set to.

Cheers
Bruce





Alberto

  • Hero Member
  • *****
  • Posts: 1873
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
Re: Spanish and utf-8 charset problem
« Reply #4 on: July 15, 2021, 03:46:15 AM »
As I said in my last post, Ive tried both
Store data as Spanish and utf-8 and got the same result, you can test it using my example.

Quote
it needs to match what is in your database.
This has nothing to do with the database, this is just strings to be translated an showed in the screen.

If I need to have a server to serve different languages, AFAIK I need utf-8, not only Spanish.

So I thought that if I convert the tranlation strings to utf-8, having the server in caraset 'utf-8' storing as utf-8 will cover all the languages.

Thanks again
« Last Edit: July 15, 2021, 03:49:29 AM by michelis »
-----------
Regards
Alberto

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Spanish and utf-8 charset problem
« Reply #5 on: July 15, 2021, 09:38:03 PM »
>> This has nothing to do with the database, this is just strings to be translated an showed in the screen.

It may not have anything to do with the database, but it has everything to do with the setting, and from that setting, how things work.

>> If I need to have a server to serve different languages, AFAIK I need utf-8, not only Spanish.

It depends on the languages. Spanish falls under "western europe" so covers spanish, english, french and so on. However once you go further out (Scandinavia, Central or Eastern Europe and so on) then it becomes better to store as utf-8.

Unfortunately storing as utf-8 though means "no reports", because clarion reports don't yet do utf-8. Well, you can have reports but extended characters will appear funny.
So if you need reports then it's best to choose a charset, if you can live without reports then it's best to use utf-8.

Whichever one you pick, you then need to manage the rest of your inputs to match. For example you are loading a value from an INI file, so this value must be encoded one, or other way as well. Plus where you use it matters - items passed through the translate method will be converted from "save as" to "charset".

Lastly, you need to manage template settings in the IDE - things you type into the IDE tend to be in a charset, not utf-8.

So, in summary, to make it work you need to know, and manage the encodings from all your sources and make sure it's in the right encoding in the right place, to match up with the "charset" and "save as" settings. When you have decided which settings you want to use then let me know and I can give you more direction as to what to do to match those settings.

cheers
Bruce