I asked chatty to explain the problem and this is what chatty said:-
The problem highlighted in the image and accompanying text concerns how VBA (Visual Basic for Applications) handles Unicode strings, specifically those that contain characters with code points above 65,535 (which includes certain emojis, rare symbols, and some Asian characters).
Problem Explanation:
VBA Limitations with Unicode:Standard VBA string functions like Len(), Right(), Instr(), etc., are not designed to properly handle Unicode characters with code points above 65,535. These characters are part of what's known as the "Supplementary Multilingual Plane" (SMP) in Unicode.
Because VBA doesn't natively support these characters correctly, functions like Len() might return incorrect string lengths, and functions like Instr() might fail to locate or properly manipulate these characters.
Incorrect Handling of Special Characters:
The issue arises because standard VBA functions may treat these high code point characters incorrectly, often splitting them or counting them incorrectly. This can lead to bugs, especially if your code relies on precise string manipulation or if you're working with complex scripts or emoji.
Solution:
To address this, the author of the text created custom Unicode string functions that correctly handle these characters.
These functions include:
LenUnicode(): Correctly calculates the length of a string, accounting for characters with code points above 65,535.
LeftUnicode(), RightUnicode(), MidUnicode(): These functions correctly extract portions of strings, taking into account high Unicode code points.
InstrUnicode(), InstrRevUnicode():
These functions correctly search for substrings within a string, recognizing characters that standard VBA functions might mishandle.
Key Points:
ContainsUnicodeAbove65K(): This function checks if the string contains any characters with code points above 65,535.
ContainsUnicodeVariationSelectors(): Checks for specific Unicode characters used to modify the appearance of preceding characters.
Why This Matters:
Even though these high code point Unicode characters are rare, they're increasingly used in modern text processing (e.g., emojis, special symbols). Ensuring that your VBA applications can handle them properly is important for creating robust and future-proof software.
In summary,
the custom functions provided by the author are designed to work around the limitations of standard VBA string functions, ensuring that all Unicode characters are handled correctly, regardless of their code point.
Please note:-
Someone that understands this issue should read through chatty's notes and point out any errors.