Unicode()

Syntax

*Buffer = Unicode(String$)
Description
Creates an Unicode representation of the string. When the buffer is no longer needed, the buffer needs to be freed with FreeMemory().

Parameters

String$ The string to use. As PureBasic uses unicode as internal string format, there is no conversion occuring.

Return value

The Unicode representation of the string.

Remarks

This function is mainly useful when interacting with third-party libraries which requires a dynamic Unicode string as input.

The buffer includes a null-terminated character.

Example

  *Unicode = Unicode("Hélé")
  ShowMemoryViewer(*Unicode, 8)

Example

  Macro TUnicode(Mem, Type = #PB_Ascii)
    PeekS(Mem, -1, Type)
  EndMacro

  *Mem1 = Ascii("Test - éàîöÊÜ")
  *Mem2 = UTF8("Test - éàîöÊÜ")
  *Mem3 = Unicode("Test - éàîöÊÜ")
  
  Debug TUnicode(*Mem1)
  ;ShowMemoryViewer(*Mem1, StringByteLength("Test - éàîöÊÜ", #PB_Ascii))   ;54 65 73 74 20 2D 20 E9 E0 EE F6 CA DC           Test - éàîöÊÜ

  Debug TUnicode(*Mem2, #PB_UTF8)
  ;ShowMemoryViewer(*Mem2, StringByteLength("Test - éàîöÊÜ", #PB_UTF8))    ;54 65 73 74 20 2D 20 C3 A9 C3 A0 C3 AE C3 B6 C3 8A C3 9C  Test - éàîöÃ

   
  Debug TUnicode(*Mem3, #PB_Unicode)
  ;ShowMemoryViewer(*Mem3, StringByteLength("Test - éàîöÊÜ", #PB_Unicode)) ;54 00 65 00 73 00 74 00 20 00 2D 00 20 00 E9 00  T.e.s.t. .-. .é.
                                                                           ; E0 00 EE 00 F6 00 CA 00 DC 00                    à.î.ö.Ê.Ü.
  
  FreeMemory(*Mem1):FreeMemory(*Mem2):FreeMemory(*Mem3)

See Also

UTF8(), Ascii(), FreeMemory(), MemorySize()

Supported OS

All

<- UnescapeString() - String Index - Val() ->