Welcome,
Guest
. Please
login
or
register
. Did you miss your
activation email?
French forum
Home
Help
Search
Login
Register
SFML community forums
»
Help
»
System
»
[SOLVED] How to convert from Glib::ustring to sf::String?
Print
Pages:
1
[
2
]
Author
Topic: [SOLVED] How to convert from Glib::ustring to sf::String? (Read 15550 times)
0 Members and 1 Guest are viewing this topic.
Laurent
Administrator
Hero Member
Posts: 32498
Re: How to convert from Glib::ustring to sf::String?
«
Reply #15 on:
January 26, 2015, 05:52:52 pm »
Can you show your code again?
Logged
Laurent Gomila - SFML developer
tapule
Newbie
Posts: 11
Re: How to convert from Glib::ustring to sf::String?
«
Reply #16 on:
January 26, 2015, 06:03:08 pm »
This doesn't work:
Glib
::
ustring
text
=
"Text: ñáéíóúö"
;
sf
::
String
string
;
string
=
sf
::
String
::
fromUtf8
(
text.
begin
(
)
, text.
end
(
)
)
;
This work
Glib
::
ustring
text
=
"Text: ñáéíóúö"
;
sf
::
String
string
;
string
=
sf
::
String
::
fromUtf16
(
text.
begin
(
)
, text.
end
(
)
)
;
and this
Glib
::
ustring
text
=
"Text: ñáéíóúö"
;
sf
::
String
string
;
string
=
sf
::
String
::
fromUtf32
(
text.
begin
(
)
, text.
end
(
)
)
;
Logged
Laurent
Administrator
Hero Member
Posts: 32498
Re: How to convert from Glib::ustring to sf::String?
«
Reply #17 on:
January 26, 2015, 07:06:24 pm »
It seems that Glib::ustring::iterator provides gunichar, which is a codepoint (UTF-32).
So the following should both work:
sf
::
String
string
=
sf
::
String
::
fromUtf32
(
text.
begin
(
)
, text.
end
(
)
)
;
sf
::
String
string
=
sf
::
String
::
fromUtf8
(
text.
raw
(
)
.
begin
(
)
, text.
raw
(
)
.
end
(
)
)
;
Logged
Laurent Gomila - SFML developer
tapule
Newbie
Posts: 11
Re: How to convert from Glib::ustring to sf::String?
«
Reply #18 on:
January 26, 2015, 07:39:35 pm »
So, as sf::String::fromUtf32 basically does an assign to the internal std::basic_string<unsigned int> that sf::String has, this is the reason that make my code work, this is, is the same behaviour.
Thank you for your time Laurent.
Logged
Print
Pages:
1
[
2
]
SFML community forums
»
Help
»
System
»
[SOLVED] How to convert from Glib::ustring to sf::String?