1. The source text must have UTF-8 encoding itself (or, more correct: it must use same UTF encoding the Windows version uses)
2. The source text must use "Unicode BOM"
3. We must tell FBC that we going to use Unicode:
3.1.
Code: Select all
#define UNICODE
4. Then we can include the windows headers:
4.1
Code: Select all
#include "windows.bi"
5. There is no default Unicode string type in FB. I've found the following workarounds:
5.1. Define the string as
Code: Select all
dim strUnicode as wstring * SomeNumber
5.2. Create user defined type
Code: Select all
Type UtfStr as wstring * SomeNumber
5.2.1. Then use this type, when you need to deal with Unicode strings, ex.
Code: Select all
dim txtBuffer as UtfStr
My summary
As we can see, the mass usage of the "5.1" method will make the code less readable.
From other side, the usage of the "5.2" method will fix the size of the Unicode string (or I'm wrong and there is a way to "enlarge' the size of that variable)
Discussion scope
Is there an "optimal" value for the wstring multiplier? I've found that 20 is not enough for me, so I used 200.
Is it possible to "enlarge" the size of the Unicode string while needed?
I would like you to check if the are any other possibilities or more elegant way to do Unicode stuff.