realesmedia
Topic Author
Posts: 85
Joined: 18 May 2016, 10:26

[C++] Locale

03 Jan 2017, 09:54

I trying to display russian symbols, but it displays as squares.
When I use data binding with my locale, program freezes.

1. How to display symbols in russian locale?
<Label Content="русский текст"/>
2. How to store string data in C++ program? I suppose NsString type not suitable for using with wchar or wstring?
Attachments
Untitled.png
Untitled.png (1.35 KiB) Viewed 1406 times
 
User avatar
jsantos
Site Admin
Posts: 2903
Joined: 20 Jan 2012, 17:18
Contact:

Re: [C++] Locale

03 Jan 2017, 12:47

We use UTF8 enconding (char*) everywhere. Make sure that you are saving the XAML with UTF8 encoding and also make sure that the font you are using has the corresponding glyphs.
 
realesmedia
Topic Author
Posts: 85
Joined: 18 May 2016, 10:26

Re: [C++] Locale

03 Jan 2017, 13:15

XAML code:
<CheckBox FontFamily="fonts/#Arial" Name="CheckListBoxItem" Content="{Binding content}" Tag="{Binding tag}" Checked="OnChecked"/>
C++ code:
Ptr<CheckListBoxItem> item1 = *new CheckListBoxItem("Элемент 1", 0);
mCheckListBoxItems->Add(item1.GetPtr());
Item "Элемент 1" displays with squares.
If i try to use wchar I get an error conversion wchar_t to NsString:
L"Элемент 1"
instead of
"Элемент 1"
.
 
User avatar
jsantos
Site Admin
Posts: 2903
Joined: 20 Jan 2012, 17:18
Contact:

Re: [C++] Locale

03 Jan 2017, 13:46

Ok, try first only with XAML, without code. Something similar to this:
<Grid xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" Background="White">
    <Viewbox>
        <TextBlock FontFamily="fonts/#Arial" Text="Элемент 1" />
    </Viewbox>
</Grid>
Save the XAML as UTF8 and check the result.
For example, if I try this XAML
<Grid xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" Background="White">
    <Viewbox>
        <TextBlock FontFamily="Fonts/#Roboto" Text="áÁéÉíÍóÓúÚñ€&#x0a;&#x0d;¹²³¼½¾&#x1d11e;" />
    </Viewbox>
</Grid>
Using the standard Roboto font all the character are displayed properly.
 
realesmedia
Topic Author
Posts: 85
Joined: 18 May 2016, 10:26

Re: [C++] Locale

03 Jan 2017, 14:29

Well, XAML with FontFamily works great. Now I need implementation of C++ sources with hard-coded russian text as in example above.
 
realesmedia
Topic Author
Posts: 85
Joined: 18 May 2016, 10:26

Re: [C++] Locale

03 Jan 2017, 15:33

Found solution when string follows after u8-prefix:
u8"Элемент 1"

Who is online

Users browsing this forum: No registered users and 2 guests