| 1 | = Printing international characters on Windows = |
---|
| 2 | |
---|
| 3 | ''Part of'' TutorialAdvanced |
---|
| 4 | |
---|
| 5 | == Description == |
---|
| 6 | |
---|
| 7 | This Windows specific code, allows you to print international characters (Greek for instance) on the non UTF-8 Windows console. |
---|
| 8 | |
---|
| 9 | == Example == |
---|
| 10 | |
---|
| 11 | {{{ |
---|
| 12 | #!d |
---|
| 13 | import std.c.stdio; |
---|
| 14 | import std.c.windows.windows; |
---|
| 15 | |
---|
| 16 | extern (Windows) { |
---|
| 17 | export BOOL CharToOemW( |
---|
| 18 | LPCWSTR lpszSrc, // string to translate |
---|
| 19 | LPSTR lpszDst // translated string |
---|
| 20 | ); |
---|
| 21 | } |
---|
| 22 | |
---|
| 23 | void main() |
---|
| 24 | { |
---|
| 25 | wchar[] s = "ΧαίÏετε!"; //Greek salutation |
---|
| 26 | echo(s); // call our function |
---|
| 27 | } |
---|
| 28 | |
---|
| 29 | void echo(wchar[] s) |
---|
| 30 | { |
---|
| 31 | char[] t = new char[s.length]; |
---|
| 32 | CharToOemW(s, t); // calling Windows API function |
---|
| 33 | puts(t); // printing translated string |
---|
| 34 | } |
---|
| 35 | }}} |
---|
| 36 | |
---|
| 37 | == Compile Instructions == |
---|
| 38 | |
---|
| 39 | Link to '''kernel32.lib''' when compiling. |
---|
| 40 | |
---|
| 41 | |
---|
| 42 | == Source == |
---|
| 43 | |
---|
| 44 | * Posted by psychotic |
---|
| 45 | * Based on http://www.digitalmars.com/d/archives/digitalmars/D/12787.html. |
---|
| 46 | |
---|
| 47 | || Link || http://www.dsource.org/tutorials/index.php?show_example=147 || |
---|
| 48 | || Posted by || Anonymous || |