Mark Dootson <mark.doot...@znix.com> writes: > Only if the input actually is valid UTF-8. Something only the Perl > coder can know / ensure. It isn't a requirement of the wxWidgets > library.
We may assume that the Perl string is in Perl's internal encoding. So I think it would be safe to encode the string in UTF-8 (this is basically what utf8::upgrade does) and pass it as an UTF-8 string to wxWidgets. > I am simply saying that one can achieve consistent results when > calling wxWidgets methods if one is explicit about the data format of > the data buffers passed. > > If there is a buffer known to contain valid UTF-8, then a simple > shortcut is utf8::upgrade($string); AFAIK, when a buffer contains valid UTF-8 (e.g., as result of an earlier decode), utf8::upgrade is a no-op. As of Perl 5.14, use feature 'unicode_strings' will make sure that all strings are, indeed, UTF-8. This takes the burden off the programmer to call utf8::upgrade (and knowing when to call it). > If I read your proposal correctly, you want to demand that all data > buffers that may get passed to the wxString conversion function are > valid UTF-8? Not really. They should be in Perl's internal coding, and thus can be safely and transparently upgraded to UTF-8. But in the end I think feature 'unicode_strings' will be the best and most elegant solution. -- Johan