MBS Xojo Developer Conference and Training
Join us from 3rd to 6th May 2017 in Berlin, Germany.

Platforms to show: All Mac Windows Linux Cross-Platform

Previous items

IsASCIIStringMBS(s as string, mode as Integer) as boolean
global method, String, MBS Util Plugin (String),
Plugin version: 3.4, Mac: Yes, Win: Yes, Linux: Yes, Console & Web: Yes, Feedback.

Function: Checks if this string is an ASCII string.
Notes:
Does not work for 16bit unicode strings.
But it works fine with UTF8.

Mode values:
0False if one of the characters of the string has a numeric value of 128 or higher. (-> string is not a 7 bit ASCII string)
1False if one of the characters of the string has a numeric value >128 or <32. (-> string may not be printable in ASCII, which may require some kind of Base64 encoding to transfer it.)
2False if one of the characters of the string has a numeric value below 32. (-> string may contain line breaks or other control characters)
Added Linux support in v5.1.

See also:

JaroWinklerDistanceMBS(a as string, b as string) as Double
global method, String, MBS Util Plugin (String),
Plugin version: 12.4, Mac: Yes, Win: Yes, Linux: Yes, Console & Web: Yes, Feedback.

Function: Calculates the string distance.
Example:
dim s1 as string = "Hello"
dim s2 as string = "Hallo"
dim s3 as string = "Helo"
dim s4 as string = "Helllo"

// 0 for equal, the more it goes to 1.0

dim d1 as Double = levenshteinDistanceMBS(s1,s1)
dim d2 as Double = levenshteinDistanceMBS(s1,s2)
dim d3 as Double = levenshteinDistanceMBS(s1,s3)
dim d4 as Double = levenshteinDistanceMBS(s1,s4)

dim d5 as Double = jaroWinklerDistanceMBS(s1,s1)
dim d6 as Double = jaroWinklerDistanceMBS(s1,s2)
dim d7 as Double = jaroWinklerDistanceMBS(s1,s3)
dim d8 as Double = jaroWinklerDistanceMBS(s1,s4)

break // check values in debugger
Notes:
Value is normalized, so 0.0 is equal text and 1.0 is totally unequal.

see also
http://en.wikipedia.org/wiki/Jaro–Winkler_distance
LevenshteinDistanceMBS(a as string, b as string) as Double
global method, String, MBS Util Plugin (String),
Plugin version: 12.4, Mac: Yes, Win: Yes, Linux: Yes, Console & Web: Yes, Feedback.

Function: Calculates the string distance.
Example:
dim s1 as string = "Hello"
dim s2 as string = "Hallo"
dim s3 as string = "Helo"
dim s4 as string = "Helllo"

// 0 for equal, the more it goes to 1.0

dim d1 as Double = levenshteinDistanceMBS(s1,s1)
dim d2 as Double = levenshteinDistanceMBS(s1,s2)
dim d3 as Double = levenshteinDistanceMBS(s1,s3)
dim d4 as Double = levenshteinDistanceMBS(s1,s4)

dim d5 as Double = jaroWinklerDistanceMBS(s1,s1)
dim d6 as Double = jaroWinklerDistanceMBS(s1,s2)
dim d7 as Double = jaroWinklerDistanceMBS(s1,s3)
dim d8 as Double = jaroWinklerDistanceMBS(s1,s4)

break // check values in debugger
Notes:
Value is normalized, so 0.0 is equal text and 1.0 is totally unequal.

see also
http://en.wikipedia.org/wiki/Levenshtein_distance
NativeStringMBS(s as string) as string
global method, String, MBS Util Plugin (String),
Plugin version: 2.7, Mac: Yes, Win: Yes, Linux: Yes, Console & Web: Yes, Feedback.

Function: Returns a native string with the given string as content.
Notes:
If the string in the parameter s is allready native it is returned unchanged and without allocating additional memory. Else the string is copied into a new string with native characters.
On Mac OS Classic native means MacRoman encoding, on Mac OS X it's UTF8 and on Windows the ANSI Codepage.
May return "" on low memory conditions.
Strings and encoding work only perfectly for RB 4.5 or newer.
Added Linux support in v5.1.

Some examples using this method:

RandomBytesStringMBS(Length as Integer, ASCII as boolean=false) as string
global method, String, MBS Util Plugin (String),
Plugin version: 9.5, Mac: Yes, Win: Yes, Linux: Yes, Console & Web: Yes, Feedback.

Function: Creates a string with random content.
Example:
dim s as string

s = RandomBytesStringMBS(10, true)

MsgBox s

s = RandomBytesStringMBS(10, false)

MsgBox s
Notes:
Length is the number of bytes in the string.
If ASCII is true the string returned in an ASCII string.

Some examples using this method:

RemoveHTMLTagsMBS(AsciiTextWithTags as string) as string
global method, String, MBS Util Plugin (String),
Plugin version: 4.1, Mac: Yes, Win: Yes, Linux: Yes, Console & Web: Yes, Feedback.

Function: Removes all html tags from the string.
Example:
msgbox RemoveHTMLTagsMBS("<P>Hello</P>") // returns "Hello"
Notes:
Returns "" on low memory.
Written to be used with UTF8 strings.
Added Linux support in v5.1.

Some examples using this method:

Some FAQ entries about this method:

RemoveHTMLTagsWithMBS(AsciiTextWithTags as string, Replacement as string) as string
global method, String, MBS Util Plugin (String),
Plugin version: 8.4, Mac: Yes, Win: Yes, Linux: Yes, Console & Web: Yes, Feedback.

Function: Removes all html tags from the string and replaces them with the replacement string.
Example:
msgbox RemoveHTMLTagsWithMBS("<P>Hello</P>"," ") // returns "   Hello   "
Notes:
Returns "" on low memory.
Written to be used with UTF8 strings.
ReplaceNonPrintableCharactersMBS(s as string, replacevalue as Integer=46) as string
global method, String, MBS Util Plugin (String),
Plugin version: 8.3, Mac: Yes, Win: Yes, Linux: Yes, Console & Web: Yes, Feedback.

Function: Replaces bytes in the string which are not printable with the given byte value.
Example:
MsgBox ReplaceNonPrintableCharactersMBS("Hello World")
MsgBox ReplaceNonPrintableCharactersMBS("Hello äöü World")
MsgBox ReplaceNonPrintableCharactersMBS("Hello äöü World",32)
Notes:
All bytes in range 32 to 127 are copied and all others replaces with the given byte value. Default is 46 which is a dot.
Returns always an ASCII string.
On low memory this function returns an empty string.

Some examples using this method:

ScientificStrMBS(d as Double, digits as Integer) as string
global method, String, MBS Util Plugin (String),
Plugin version: 11.1, Mac: Yes, Win: Yes, Linux: Yes, Console & Web: Yes, Feedback.

Function: Returns the given value formatted as scientific number with the given number of digits.
Example:
dim d as Double = 3.1415926535897

MsgBox ScientificStrMBS(d,6)+EndOfLine+ScientificStrMBS(d,9)
SplitMBS(value as String, delimiter as String = " ") as String()
global method, String, MBS DataTypes Plugin (StringHandle),
Plugin version: 16.4, Mac: Yes, Win: Yes, Linux: Yes, Console & Web: Yes, Feedback.

Function: Splits string.
Example:
dim a() as string = SplitMBS("Hello World Test", " ")
dim b() as string = SplitMBS("Grüße", "")
dim c() as string = SplitMBS("Just$test$a$test$test", "$test$")

break
Notes:
Similar to the Split() function, but without the problems we see with Split function. See feedback cases for Split.

If delimiter is "", we return an array with all characters in string.
Else we split given string with delimiter.
SQLReplaceBooleanMBS(SQL as string) as string
global method, String, MBS Util Plugin (String),
Plugin version: 10.3, Mac: Yes, Win: Yes, Linux: Yes, Console & Web: Yes, Feedback.

Function: Replaces all false/true strings with 0/1 and handles quotes correctly.
Example:
MsgBox SQLReplaceBooleanMBS("INSERT INTO criteria VALUES ('1','9999','0001','000001557',false);")
Notes:
SQLite used in REALSQLDatabase does not like false and true literals for boolean values. You need to use 0 and 1. So this function helps you converting old queries using false/true.
false and true inside a quoted string are not changed.
StrCompBytesMBS(a as string, b as string) as Integer
global method, String, MBS Util Plugin (String),
Plugin version: 9.1, Mac: Yes, Win: Yes, Linux: Yes, Console & Web: Yes, Feedback.

Function: Compares two strings.
Example:
msgbox str(StrCompBytesMBS("Hello","hello"))
Notes:
Returns zero if the two strings are identical.
Returns 1 or -1 if the strings are different.
Empty strings are equal.

Compares the bytes of both strings independend of the text encoding.

So if a="A" in UTF-8 and b="A" in UTF-16 they will not be equal!

Some examples using this method:

StrCompCharactersMBS(a as string, b as string) as Integer
global method, String, MBS Util Plugin (String),
Plugin version: 9.1, Mac: Yes, Win: Yes, Linux: Yes, Console & Web: Yes, Feedback.

Function: Compares two strings.
Example:
msgbox str(StrCompCharactersMBS("Hello","hello"))
Notes:
Returns zero if the two strings are identical.
Returns 1 or -1 if the strings are different.
Empty strings are equal.

Compares the characters of both strings. If the text encodings are not equal, they are both converted to UTF-8 before comparing them.

So if a="A" in UTF-8 and b="A" in UTF-16 they will be equal!
StringANDMBS(a as string,b as string) as string
global method, String, MBS Util Plugin (String),
Plugin version: 3.1, Mac: Yes, Win: Yes, Linux: Yes, Console & Web: Yes, Feedback.

Function: Applies a binary AND on the bytes from the both strings.
Notes:
If a is "" or memory is low, the result is "".
If b is shorter as a the b string is used several times.
The function is optimized for several cases, e.g. the case where b is only one, two or four bytes long.
Returns a string with binary encoding. Before using this function, make sure both strings have the same encoding.
Added Linux support in v5.1.

Some examples using this method:

StringIsHTMLreadyMBS(s as string) as boolean
global method, String, MBS Util Plugin (String),
Plugin version: 7.6, Mac: Yes, Win: Yes, Linux: Yes, Console & Web: Yes, Feedback.

Function: Test whether a string is html safe.
Example:
Function html(t as string) As string
#pragma disablebackgroundtasks
#pragma disableautowaitcursor

if StringIsHTMLreadyMBS(t) then
Return t
else
t=EncodingToHTMLMBS(t)
Return ConvertEncoding(t,encodings.UTF8)
end if
End Function
Notes:
String which are not html safe, need to go through EncodingToHTMLMBS.
Using this function saves a lot of time!

Returns true for strings which are html safe.
StringIsXMLreadyMBS(s as string) as boolean
global method, String, MBS Util Plugin (String),
Plugin version: 15.2, Mac: Yes, Win: Yes, Linux: Yes, Console & Web: Yes, Feedback.

Function: Test whether a string is xml safe.
Notes:
String which are not html safe, need to go through EncodingToXMLMBS.
Using this function saves a lot of time!

Returns true for strings which are xml safe.
StringORMBS(a as string,b as string) as string
global method, String, MBS Util Plugin (String),
Plugin version: 3.1, Mac: Yes, Win: Yes, Linux: Yes, Console & Web: Yes, Feedback.

Function: Applies a binary OR on the bytes from the both strings.
Notes:
If a is "" or memory is low, the result is "".
If b is shorter as a the b string is used several times.
The function is optimized for several cases, e.g. the case where b is only one, two or four bytes long.
Returns a string with binary encoding. Before using this function, make sure both strings have the same encoding.
Added Linux support in v5.1.

Some examples using this method:

StringXOR2MBS(data as string, XorMask as string, MaskOffset as Integer = 0) as string
global method, String, MBS Util Plugin (String),
Plugin version: 3.1, Mac: Yes, Win: Yes, Linux: Yes, Console & Web: Yes, Feedback.

Function: Applies a binary XOR on the bytes from the both strings.
Example:
dim s as string = StringXORMBS("Hello", "World")
dim t as string = StringXOR2MBS("Hello", "World")

MsgBox EncodeHex(S)+" "+EncodeHex(t)

dim ss as string = StringXORMBS(s, "World")
dim tt as string = StringXOR2MBS(t, "World")

MsgBox ss+" "+tt
Notes:
If data is "" or memory is low, the result is "".
If XorMask is shorter as data the XorMask string is used several times.
Returns a string with binary encoding. Before using this function, make sure both strings have the same encoding.

The difference between StringXORMBS and StringXOR2MBS is that the second version xors also with position of byte in string, so your text looks a little bit more random.
MaskOffset specifies where in the XorMask string to start. This is useful for partial blocks.
StringXORMBS(data as string, XorMask as string, MaskOffset as Integer = 0) as string
global method, String, MBS Util Plugin (String),
Plugin version: 3.1, Mac: Yes, Win: Yes, Linux: Yes, Console & Web: Yes, Feedback.

Function: Applies a binary XOR on the bytes from the both strings.
Notes:
If data is "" or memory is low, the result is "".
If XorMask is shorter as data the XorMask string is used several times.
The function is optimized for several cases, e.g. the case where b is only one, two or four bytes long.
Returns a string with binary encoding. Before using this function, make sure both strings have the same encoding.
MaskOffset specifies where in the XorMask string to start. This is useful for partial blocks.

Some examples using this method:

StrMBS(d as Double) as string
global method, String, MBS Util Plugin (String),
Plugin version: 11.1, Mac: Yes, Win: Yes, Linux: Yes, Console & Web: Yes, Feedback.

Function: Formats numbers more human readable
Example:
// shows: 0.000000012339 1.234560e-8
MsgBox StrMBS(0.00000001234)+" "+str(0.00000001234)

// shows 123456789.0 1.234568e+8
MsgBox StrMBS(123456789.0)+" "+str(123456789.0)
Notes: The idea is to have a dynamically changing number of digits. We have no scientific notation and up to 15 digits visible (not counting zeros).

Some examples using this method:

UnicodeStringMBS(s as string) as string
global method, String, MBS Util Plugin (String),
Plugin version: 2.7, Mac: Yes, Win: Yes, Linux: Yes, Console & Web: Yes, Feedback.

Function: Returns a unicode string with the given string as content.
Notes:
If the string in the parameter s is allready unicode it is returned unchanged and without allocating additional memory. Else the string is copied into a new string with unicode (16bit) characters.
May return "" on low memory conditions.
Strings and encoding work only perfectly for RB 4.5 or newer.
Added Linux support in v5.1.

The result of this function is unpredictable on bad input strings.
(e.g. no encoding, or encoding does not match the content of the string)

Some examples using this method:

Previous items

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




Links
MBS FileMaker Plugins