Aarón Bueno Villares
2016-10-28 06:43:45 UTC
I was trying to bind a simple string to a `WTemplate`, containing a euro
sign:
<message id="msg">60â¬</message>
tmpl->bindString("placeholder", tr("msg"));
But instead of render the ⬠symbol, a ? is written in the HTML output
instead. That's is because, when rendering the template, if a variable
placeholder is binded to a string instead of a widget, the string
(`WString` internally) is written to the stream using `operator<<`
(WTemplate::resolveString).
And the implementation of `operator<<` pass forcefully through
`Wt::narrow`, which discards non-ASCII-7 symbols (like â¬), replacing them
by '?'.
I tried to change ⬠by €, but, when parsing the localized string file,
code entities are replace by their unicode versions (which are later
replaced by ? when writting to the buffer).
My only change is to bind a `WText` instead of a string:
tmpl->bindWidget("placeholder", new Wt::WText(tr("msg")));
And the ⬠symbol is correctly displayed.
Is that a bug? Is still present in current versions? (mine is 3.3.4).
sign:
<message id="msg">60â¬</message>
tmpl->bindString("placeholder", tr("msg"));
But instead of render the ⬠symbol, a ? is written in the HTML output
instead. That's is because, when rendering the template, if a variable
placeholder is binded to a string instead of a widget, the string
(`WString` internally) is written to the stream using `operator<<`
(WTemplate::resolveString).
And the implementation of `operator<<` pass forcefully through
`Wt::narrow`, which discards non-ASCII-7 symbols (like â¬), replacing them
by '?'.
I tried to change ⬠by €, but, when parsing the localized string file,
code entities are replace by their unicode versions (which are later
replaced by ? when writting to the buffer).
My only change is to bind a `WText` instead of a string:
tmpl->bindWidget("placeholder", new Wt::WText(tr("msg")));
And the ⬠symbol is correctly displayed.
Is that a bug? Is still present in current versions? (mine is 3.3.4).