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 &euro;, 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).
------------------------------------------------------------------------------
The Command Line: Reinvented for Modern Developers
Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive. 
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik
_______________________________________________
witty-interest mailing list
witty-interest@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/witty-interest

Reply via email to