Ascii()

Syntax

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

Parameters

String$ The string to convert.

Return value

The Ascii representation of the string.

Remarks

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

The buffer includes a null-terminated character.

Example

  *Ascii = Ascii("Hélé")
  ShowMemoryViewer(*Ascii, 4)

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(), Unicode(), FreeMemory(), MemorySize()

Supported OS

All

<- Asc() - String Index - Bin() ->