Page 1 of 1

[C++] Locale

Posted: 03 Jan 2017, 09:54
by realesmedia
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?

Re: [C++] Locale

Posted: 03 Jan 2017, 12:47
by jsantos
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.

Re: [C++] Locale

Posted: 03 Jan 2017, 13:15
by realesmedia
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"
.

Re: [C++] Locale

Posted: 03 Jan 2017, 13:46
by jsantos
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.

Re: [C++] Locale

Posted: 03 Jan 2017, 14:29
by realesmedia
Well, XAML with FontFamily works great. Now I need implementation of C++ sources with hard-coded russian text as in example above.

Re: [C++] Locale

Posted: 03 Jan 2017, 15:33
by realesmedia
Found solution when string follows after u8-prefix:
u8"Элемент 1"