Jean-Marc Lasgouttes <[EMAIL PROTECTED]> writes:

> 
> >>>>> "Jean-Marc" == Jean-Marc Lasgouttes <[EMAIL PROTECTED]> writes:
> Jean-Marc> I'd be interested to know how I could have made it shorter,
> Jean-Marc> and whether it is right. I have to say I do not like it
> Jean-Marc> much :)
> 
> OK, now that I have tried it, I see I forgot to handle draw() too.
> This leads me to some code refactoring, and the result looks nice
> (provided we have some support functions for _() and bformat).

+docstring macroprefix(string const & name)
 {
-       return bformat(_(" Macro: %1$s: "), name_);
+       string pref = bformat(_(" Macro: %1$s: "), name);
+       vector<char> utf8pref(pref.begin(), pref.end());
+       vector<uint32_t> ucs4pref = 
+               utf8_to_ucs4(vector<char>(utf8pref.begin(), 
+                                         utf8pref.end()));
+       return docstring(ucs4pref.begin(), ucs4pref.end());
+}

What encoding does "name" have? How is it generated? Shouldn't it eventually 
be a docstring itself? Similarly, if _(" Macro: %1$s: ") eventually returns a 
UCS-4 docstring, then bformat takes two docstring arguments to, presumably, 
return a docstring itself.

So the whole UTF-8 -> USC-4 thing just dissappears in the wash. Eventually.

Have I got it right? Is your current code just a band-aid?

Angus

Reply via email to