String: CheckUTF8MBS

Online Documentation   -   Statistics   -   FAQ   -   Plugin Parts (All, Dependencies)   -   Class hierarchy

New in Version 22.2 22.3 22.4 22.5 23.0 23.1 23.2 23.3 23.4 23.5 24.0 24.1

The list of the   topics,   classes,   interfaces,   controls,   modules,   global methods by category,   global methods by name,   screenshots,   licenses   and   examples.

Platforms to show: All Mac Windows Linux Cross-Platform

CheckUTF8MBS(data as ptr, size as Integer, Placeholder as string) as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
global method String MBS Util Plugin 16.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Returns string as UTF-8 and replacing invalid UTF-8 sequences with placeholder.

This function is more save than simply DefineEncoding as it makes sure the returned text actually is valid UTF-8.
You can replace missing characters with empty text, question mark or any other symbol.

This function is overloaded, so you can directly pass in string, memoryblock or ptr+size.
Checks byte sequence with up to 4 byte long sequences. Does not verify whether code points are valid.

See also:

CheckUTF8MBS(data as string, Placeholder as string) as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
global method String MBS Util Plugin 16.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Returns string as UTF-8 and replacing invalid UTF-8 sequences with placeholder.
Example
// some random bytes
dim t as string = RandomBytesStringMBS(20, false)

// and some text
t = t + " äöü 😀"

// checked
dim s as string = CheckUTF8MBS(t, "😂")

MsgBox s

This function is more save than simply DefineEncoding as it makes sure the returned text actually is valid UTF-8.
You can replace missing characters with empty text, question mark or any other symbol.

This function is overloaded, so you can directly pass in string, memoryblock or ptr+size.
Checks byte sequence with up to 4 byte long sequences. Does not verify whether code points are valid.

See also:

CheckUTF8MBS(mem as MemoryBlock, Placeholder as string) as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
global method String MBS Util Plugin 16.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Returns string as UTF-8 and replacing invalid UTF-8 sequences with placeholder.
Example
// some random bytes
dim t as string = RandomBytesStringMBS(20, false)

// and some text
t = t + " äöü 😀"

// checked in memoryblock
dim m as MemoryBlock = t
dim s as string = CheckUTF8MBS(m, "😂")

MsgBox s

This function is more save than simply DefineEncoding as it makes sure the returned text actually is valid UTF-8.
You can replace missing characters with empty text, question mark or any other symbol.

This function is overloaded, so you can directly pass in string, memoryblock or ptr+size.
Checks byte sequence with up to 4 byte long sequences. Does not verify whether code points are valid.

See also:

Blog Entries

Xojo Developer Magazine

The items on this page are in the following plugins: MBS Util Plugin.


💬 Ask a question or report a problem