UTF8()

Syntax

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

Parameters

String$ The string to convert.

Return value

The UTF8 representation of the string.

Remarks

This function is mainly useful when interacting with third-party libraries which requiers UTF8 as input. Pseudotype 'p-utf8' can also be used to automated the converting process when importing external functions.

The buffer includes a null-terminated character.

Example

  *UTF8 = UTF8("Hl")
  ShowMemoryViewer(*UTF8, 6)
    
  Debug PeekS(*Ascii, -1, #PB_Ascii) ; Displays "Hl"

Example

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

  *Mem1 = Ascii("Test - ")
  *Mem2 = UTF8("Test - ")

  Text.s = Unicode(*Mem1)
  Debug Text 

  Text2.s = Unicode(*Mem2, #PB_UTF8)
  Debug Text2 

See Also

Ascii()

Supported OS

All

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