Note: This website is archived. For up-to-date information about D projects and development, please visit wiki.dlang.org.

Changes from Version 1 of PrintingInternationalCharactersExamples

Show
Ignore:
Author:
jcc7 (IP: 68.97.93.38)
Timestamp:
11/21/05 02:27:45 (18 years ago)
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • PrintingInternationalCharactersExamples

    v0 v1  
     1= Printing international characters on Windows = 
     2 
     3''Part of'' TutorialAdvanced 
     4 
     5== Description == 
     6 
     7This 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 
     13import std.c.stdio; 
     14import std.c.windows.windows; 
     15 
     16extern (Windows) { 
     17    export BOOL CharToOemW( 
     18            LPCWSTR lpszSrc, // string to translate 
     19            LPSTR lpszDst // translated string 
     20    ); 
     21} 
     22 
     23void main() 
     24{ 
     25    wchar[] s = "Χαίρετε!"; //Greek salutation 
     26    echo(s); // call our function 
     27} 
     28 
     29void 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 
     39Link 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 ||