[cfe-dev] Convert char to wchar_t?

Aaron Wishnick aaron.s.wishnick at gmail.com
Sat May 26 13:07:53 PDT 2012


I'm working on bug 11789: http://llvm.org/bugs/show_bug.cgi?id=11789

As part of it, I need to take a C string for a PredefinedExpr, and emit the equivalent wchar_t string literal. Right now my code just casts chars to wchar_t, but I realize this isn't right, since it will break whenever clang is targeting a platform other than that which it was compiled on. My question is, is there an example of existing code for taking a string, encoded as char, and turning it into an array of bytes appropriately encoded as wchar_t for the target platform? If not, could anybody point me to a safe way to do this? Thanks!

Best regards,
Aaron
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120526/586ce0d6/attachment.html>


More information about the cfe-dev mailing list