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
Function: Returns string as UTF-8 and replacing invalid UTF-8 sequences with placeholder.
Notes:
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:

Feedback, Comments & Corrections

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
Function: 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
Notes:
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:

Feedback, Comments & Corrections

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
Function: 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
Notes:
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

Feedback, Comments & Corrections

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

The biggest plugin in space...




Links
MBS Xojo Plugins

Start Chat