Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Libraries and TheIDE: i18n, Unicode and Internationalization » CHARSET_UTF8 not working?
CHARSET_UTF8 not working? [message #48508] Tue, 11 July 2017 13:22 Go to next message
rafiwui is currently offline  rafiwui
Messages: 105
Registered: June 2017
Location: Stuttgart, Germany
Experienced Member
Trying to make an internationalized application I came across an issue when I tried sth in czech language:
#include <CtrlLib/CtrlLib.h>
using namespace Upp;

#define TFILE <main/test.t>
#include <Core/t.h>

GUI_APP_MAIN
{
    SetLanguage(LNG_CZECH);
    SetDefaultCharset(CHARSET_UTF8);
    TopWindow app;
    app.SetRect(0, 0, 200, 20);
    app.Title(t_("Application"));
    app.Run();
}


test.t:
T_("Application")
csCZ("přihláška")


Running this results in the following output:
index.php?t=getfile&id=5339&private=0

When I comment out
SetDefaultCharset(CHARSET_UTF8);

it works perfectly:
index.php?t=getfile&id=5340&private=0

But it only works when I have my language set to czech and that is not what I want to achieve.

Am I missing sth here? And how can I get UTF8/Unicode to work properly?
  • Attachment: Upp1.PNG
    (Size: 0.72KB, Downloaded 534 times)
  • Attachment: Upp2.PNG
    (Size: 1.05KB, Downloaded 467 times)


Greetings
Daniel
Re: CHARSET_UTF8 not working? [message #48548 is a reply to message #48508] Fri, 21 July 2017 11:40 Go to previous messageGo to next message
rafiwui is currently offline  rafiwui
Messages: 105
Registered: June 2017
Location: Stuttgart, Germany
Experienced Member
Anyone willing to help me with this?

Greetings
Daniel
Re: CHARSET_UTF8 not working? [message #48550 is a reply to message #48548] Fri, 21 July 2017 11:57 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1091
Registered: August 2007
Senior Contributor
Hello rafiwui,

Quote:
wui
Anyone willing to help me with this?


Sure Smile

But please provide us a simple testcase (example code (packed preferably with zip)) that isolates the problem, so that we can examime it on our machines.

Best regards,
Oblivion


[Updated on: Fri, 21 July 2017 11:58]

Report message to a moderator

Re: CHARSET_UTF8 not working? [message #48551 is a reply to message #48550] Fri, 21 July 2017 12:07 Go to previous messageGo to next message
rafiwui is currently offline  rafiwui
Messages: 105
Registered: June 2017
Location: Stuttgart, Germany
Experienced Member
Sorry I thought my codesnippet would be enough because it is such a small example.
Here comes the zip Smile


Greetings
Daniel
Re: CHARSET_UTF8 not working? [message #48553 is a reply to message #48551] Fri, 21 July 2017 14:44 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1091
Registered: August 2007
Senior Contributor
Hello rafiwui,

I don't see antyhing wrong with the code or U++.

Quote:
]But it only works when I have my language set to czech and that is not what I want to achieve.


As you know, U++ *.t files are meant be used for localization. But you don't really need use the English versions of the strings as default (or at all).

if in the *.cpp file you can simpyl write:

app.Title(t_("přihláška"));


This will make it the default string (the string to be localized, if needed.).

Also you don't need to call:

SetDefaultCharset(CHARSET_UTF8);


UTF8 is/should be enabled by default. This function is to support legacy applications.

Best regards,
Oblivion


[Updated on: Fri, 21 July 2017 14:54]

Report message to a moderator

Re: CHARSET_UTF8 not working? [message #48555 is a reply to message #48553] Fri, 21 July 2017 15:16 Go to previous messageGo to next message
rafiwui is currently offline  rafiwui
Messages: 105
Registered: June 2017
Location: Stuttgart, Germany
Experienced Member
Oblivion wrote on Fri, 21 July 2017 14:44


As you know, U++ *.t files are meant be used for localization. But you don't really need use the English versions of the strings as default (or at all).

if in the *.cpp file you can simpyl write:

app.Title(t_("přihláška"));


This will make it the default string (the string to be localized, if needed.).


Two points on this:
1. I learned that it is no good programming style to put non-ASCII letters in pure source code Wink Smile
2. But I want a multinational application, so I need different language support and I don't know how to achieve this in this way.


Oblivion wrote on Fri, 21 July 2017 14:44


Also you don't need to call:

SetDefaultCharset(CHARSET_UTF8);


UTF8 is/should be enabled by default. This function is to support legacy applications.


It is even more curious that the string got "destroyed" then.
By the way: If I do it the way you showed me (put the czech string in the code) and don't uncomment the SetDefaultChar it works.
But why? Why doesn't it take the string correctly from the .t file but from the source code?


Greetings
Daniel
Re: CHARSET_UTF8 not working? [message #48556 is a reply to message #48555] Fri, 21 July 2017 17:12 Go to previous message
Oblivion is currently offline  Oblivion
Messages: 1091
Registered: August 2007
Senior Contributor
Quote:

1. I learned that it is no good programming style to put non-ASCII letters in pure source code.


Fair point. But not necessarily true. But that's another story... Smile

Quote:

2. But I want a multinational application, so I need different language support and I don't know how to achieve this in this way.



I've attached a simple example which changes the app title, and static text to English, Czech, and Turkish, using a droplist. Maybe it'll give you an idea.


Quote:
But why? Why doesn't it take the string correctly from the .t file but from the source code?



It does. But *.t files are AFAIK component/application-wide, and applied on initialization (not sure about the latter though). It'll pick up the Czech version of the strings only when the language is set to Czech (or the default strings are in Czech).




[Updated on: Fri, 21 July 2017 17:31]

Report message to a moderator

Previous Topic: Theide (feature): closing openend files when changing package
Next Topic: Custom Build Steps to generate .cpp files and then compile
Goto Forum:
  


Current Time: Tue Mar 19 09:17:58 CET 2024

Total time taken to generate the page: 0.01407 seconds