n_cst_unicode.sru 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. $PBExportHeader$n_cst_unicode.sru
  2. forward
  3. global type n_cst_unicode from nonvisualobject
  4. end type
  5. end forward
  6. global type n_cst_unicode from nonvisualobject autoinstantiate
  7. end type
  8. type prototypes
  9. FUNCTION ulong MultiByteToWideChar( unsignedinteger codepage, unsignedlong dwflags, ref string lpmultibytestr, integer cbmultibyte, ref blob lpwidecharstr, integer cchwidechar ) LIBRARY "kernel32.dll" alias for "MultiByteToWideChar;Ansi"
  10. FUNCTION ulong WideCharToMultiByte( unsignedinteger codepage, unsignedlong dwflags, ref blob lpwidecharstr, integer cchwidechar, ref string lpmultibytestr, integer cchmultibyte, ref character lpdefaultchar, ref boolean lpuseddefaultchar ) LIBRARY "kernel32.dll" alias for "WideCharToMultiByte;Ansi"
  11. end prototypes
  12. type variables
  13. PUBLIC INTEGER mb_precomposed = 1
  14. PUBLIC INTEGER mb_composite = 2
  15. PUBLIC INTEGER mb_useglyphchars = 4
  16. PUBLIC INTEGER wc_defaultcheck = 256
  17. PUBLIC INTEGER wc_compositecheck = 512
  18. PUBLIC INTEGER wc_discardns = 16
  19. PUBLIC INTEGER wc_sepchars = 32
  20. PUBLIC INTEGER wc_defaultchar = 64
  21. end variables
  22. forward prototypes
  23. public function blob of_ansi2unicode (string as_value, unsignedlong ai_codepage)
  24. public function blob of_ansi2unicode (string as_value)
  25. public function string of_unicode2ansi (blob a_value, unsignedinteger ai_codepage)
  26. public function string of_unicode2ansi (blob a_value, unsignedinteger ai_codepage, character ac_default_char)
  27. public function string of_unicode2ansi (blob a_value)
  28. end prototypes
  29. public function blob of_ansi2unicode (string as_value, unsignedlong ai_codepage);//BLOB lc_buff
  30. //ULONG li_output_size
  31. //STRING ls_temp_buff
  32. //ULONG li_input_size
  33. //
  34. //SETNULL(lc_buff)
  35. //li_input_size = LEN(as_value)
  36. //li_output_size = multibytetowidechar(ai_codepage, 0, as_value, li_input_size, lc_buff, 0)
  37. //
  38. //IF li_output_size > 0 THEN
  39. // ls_temp_buff = SPACE(li_output_size * 2)
  40. // lc_buff = BLOB(ls_temp_buff)
  41. // li_output_size = multibytetowidechar(ai_codepage, 0, as_value, li_input_size, lc_buff, li_output_size)
  42. //ELSE
  43. // lc_buff = BLOB("")
  44. //END IF
  45. //
  46. //RETURN lc_buff
  47. Return Blob(as_Value)
  48. end function
  49. public function blob of_ansi2unicode (string as_value);RETURN of_ansi2unicode(as_value,0)
  50. end function
  51. public function string of_unicode2ansi (blob a_value, unsignedinteger ai_codepage);//integer li_input_size
  52. //integer li_output_size
  53. //string ls_buff
  54. //char lc_def_char
  55. //boolean lb_use_def_char
  56. //
  57. //li_input_size = len(a_value) / 2
  58. //li_output_size = widechartomultibyte(ai_codepage, 0, a_value, li_input_size, ls_buff, 0, lc_def_char, lb_use_def_char)
  59. //ls_buff = space(li_output_size)
  60. //lc_def_char = "?"
  61. //lb_use_def_char = true
  62. //widechartomultibyte(ai_codepage, 0, a_value, li_input_size, ls_buff, li_output_size, lc_def_char, lb_use_def_char)
  63. //return ls_buff
  64. Return String(a_Value)
  65. end function
  66. public function string of_unicode2ansi (blob a_value, unsignedinteger ai_codepage, character ac_default_char);//integer li_input_size
  67. //integer li_output_size
  68. //string ls_buff
  69. //char lc_def_char
  70. //boolean lb_use_def_char
  71. //
  72. //li_input_size = len(a_value) / 2
  73. //li_output_size = widechartomultibyte(ai_codepage, 0, a_value, li_input_size, ls_buff, 0, lc_def_char, lb_use_def_char)
  74. //ls_buff = space(li_output_size)
  75. //lc_def_char = ac_default_char
  76. //lb_use_def_char = true
  77. //widechartomultibyte(ai_codepage, 0, a_value, li_input_size, ls_buff, li_output_size, lc_def_char, lb_use_def_char)
  78. //return ls_buff
  79. Return String(a_Value)
  80. end function
  81. public function string of_unicode2ansi (blob a_value);return of_unicode2ansi(a_value,0)
  82. end function
  83. on n_cst_unicode.create
  84. call super::create
  85. TriggerEvent( this, "constructor" )
  86. end on
  87. on n_cst_unicode.destroy
  88. TriggerEvent( this, "destructor" )
  89. call super::destroy
  90. end on