fork download
  1. private import std.c.windows.windows;
  2. private import std.windows.syserror;
  3. private import std.utf;
  4. private import std.string;
  5.  
  6. string charctorEncodingConvert(const(char[]) str, uint formCodePage, uint toCodePage)
  7. {
  8. version(Windows)
  9. {
  10. int result;
  11. wchar[] wstr;
  12. char[] rstr;
  13.  
  14. result = MultiByteToWideChar(formCodePage, 0, str.ptr, str.length, null, 0);
  15. wstr.length = result;
  16. MultiByteToWideChar(formCodePage, 0, str.ptr, str.length, wstr.ptr, wstr.length);
  17.  
  18. result = WideCharToMultiByte(toCodePage, 0, wstr.ptr, wstr.length, null, 0, null, null);
  19. rstr.length = result;
  20. WideCharToMultiByte(toCodePage, 0, wstr.ptr, wstr.length, rstr.ptr, rstr.length, null, null);
  21.  
  22. return cast(immutable)rstr;
  23. }
  24. else version(Posix)
  25. {
  26. }
  27. else
  28. {
  29. static assert(0);
  30. }
  31. }
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty