Mercurial > projects > dwt2
comparison org.eclipse.swt.win32.win32.x86/src/org/eclipse/swt/internal/win32/OS.d @ 9:950d84783eac
Removing direct tango deps.
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Mon, 09 Mar 2009 14:26:40 +0100 |
parents | 2847134a5fc0 |
children | 735224fcc45f |
comparison
equal
deleted
inserted
replaced
8:2847134a5fc0 | 9:950d84783eac |
---|---|
23 static import tango.sys.SharedLib; | 23 static import tango.sys.SharedLib; |
24 static import tango.sys.Common; | 24 static import tango.sys.Common; |
25 | 25 |
26 static import tango.stdc.stdlib; | 26 static import tango.stdc.stdlib; |
27 static import tango.stdc.string; | 27 static import tango.stdc.string; |
28 static import tango.text.convert.Utf; | |
29 static import tango.io.Console; | |
30 | 28 |
31 alias tango.sys.win32.UserGdi WINAPI; | 29 alias tango.sys.win32.UserGdi WINAPI; |
32 alias org.eclipse.swt.internal.win32.WINAPI DWTWINAPI; | 30 alias org.eclipse.swt.internal.win32.WINAPI DWTWINAPI; |
33 | 31 |
34 void trace(int line ){ | 32 void trace(int line ){ |
3601 | 3599 |
3602 alias DWTWINAPI.GetScrollBarInfo GetScrollBarInfo; | 3600 alias DWTWINAPI.GetScrollBarInfo GetScrollBarInfo; |
3603 } // END of OS | 3601 } // END of OS |
3604 //----------------------------------------------------------------------------- | 3602 //----------------------------------------------------------------------------- |
3605 import tango.sys.win32.CodePage : CodePage; | 3603 import tango.sys.win32.CodePage : CodePage; |
3606 private import tango.text.convert.Utf; | |
3607 private import tango.stdc.stringz; | 3604 private import tango.stdc.stringz; |
3608 | 3605 |
3609 // convert UTF-8 to MBCS | 3606 // convert UTF-8 to MBCS |
3610 alias StrToMBCS StrToMBCSs; | 3607 alias StrToMBCS StrToMBCSs; |
3611 public CHAR[] StrToMBCS(char[] sc, uint codepage = 0) { | 3608 public CHAR[] StrToMBCS(char[] sc, uint codepage = 0) { |
3614 foreach (char c; sc){ | 3611 foreach (char c; sc){ |
3615 if (c >= 0x80) | 3612 if (c >= 0x80) |
3616 { | 3613 { |
3617 CHAR[] result; | 3614 CHAR[] result; |
3618 int i; | 3615 int i; |
3619 wchar[] ws = tango.text.convert.Utf.toString16(sc); | 3616 wchar[] ws = toWCharArray(sc); |
3620 result.length = OS.WideCharToMultiByte(codepage, 0, ws.ptr, ws.length, null, 0, null, null); | 3617 result.length = OS.WideCharToMultiByte(codepage, 0, ws.ptr, ws.length, null, 0, null, null); |
3621 i = OS.WideCharToMultiByte(codepage, 0, ws.ptr, ws.length, result.ptr, result.length, null, null); | 3618 i = OS.WideCharToMultiByte(codepage, 0, ws.ptr, ws.length, result.ptr, result.length, null, null); |
3622 assert(i == result.length); | 3619 assert(i == result.length); |
3623 return result; | 3620 return result; |
3624 } | 3621 } |
3652 return StrToWCHARs( sc, terminated ); | 3649 return StrToWCHARs( sc, terminated ); |
3653 } | 3650 } |
3654 public wchar[] StrToWCHARs(char[] sc, bool terminated = false ) { | 3651 public wchar[] StrToWCHARs(char[] sc, bool terminated = false ) { |
3655 wchar[] ret; | 3652 wchar[] ret; |
3656 try{ | 3653 try{ |
3657 ret = tango.text.convert.Utf.toString16(sc); | 3654 ret = toWCharArray(sc); |
3658 }catch(Exception e){ | 3655 }catch(Exception e){ |
3659 // do nothing | 3656 // do nothing |
3660 ret = ""; | 3657 ret = ""; |
3661 } | 3658 } |
3662 if( terminated ){ | 3659 if( terminated ){ |
3689 return null; | 3686 return null; |
3690 | 3687 |
3691 wchar[] wcs = _mbcszToWs(pString, _length, codepage); | 3688 wchar[] wcs = _mbcszToWs(pString, _length, codepage); |
3692 char[] result; | 3689 char[] result; |
3693 try{ | 3690 try{ |
3694 result = .toString(wcs); | 3691 result = String_valueOf(wcs); |
3695 }catch(Exception e){ | 3692 }catch(Exception e){ |
3696 } | 3693 } |
3697 return result; | 3694 return result; |
3698 } | 3695 } |
3699 | 3696 |
3717 // convert wchar* to UTF-8 | 3714 // convert wchar* to UTF-8 |
3718 wchar[] wcs = pString[0.._length]; | 3715 wchar[] wcs = pString[0.._length]; |
3719 | 3716 |
3720 char[] result; | 3717 char[] result; |
3721 try{ | 3718 try{ |
3722 result = .toString(wcs); | 3719 result = String_valueOf(wcs); |
3723 }catch(Exception e){ | 3720 }catch(Exception e){ |
3724 // do nothing | 3721 // do nothing |
3725 } | 3722 } |
3726 return result; | 3723 return result; |
3727 } | 3724 } |