Printing international characters on Windows
Part of TutorialAdvanced
Description
This Windows specific code, allows you to print international characters (Greek for instance) on the non UTF-8 Windows console.
Example
import std.c.stdio; import std.c.windows.windows; extern (Windows) { export BOOL CharToOemW( LPCWSTR lpszSrc, // string to translate LPSTR lpszDst // translated string ); } void main() { wchar[] s = "ΧαίÏετε!"; //Greek salutation echo(s); // call our function } void echo(wchar[] s) { char[] t = new char[s.length]; CharToOemW(s, t); // calling Windows API function puts(t); // printing translated string }
Compile Instructions
Link to kernel32.lib when compiling.
Source
- Posted by psychotic
- Based on http://www.digitalmars.com/d/archives/digitalmars/D/12787.html.
| Link | http://www.dsource.org/tutorials/index.php?show_example=147 |
| Posted by | Anonymous |
