One of the excellent programs Richard has included in his "Examples" is TextEdit. I've learned a lot from it and found it very useful.
Welsh can have a circumflex over all its vowels, as for example, in the famous hymn
Calon Lân
Anghofio'i annwyl ŵyn
is a line from another hymn.
If you copy and paste those two lines into Notepad and save the file as UTF-8, you can load it in again and everything is fine. Start up TextEdit and load the file in and the result is "Calon Lân". I have changed to RichEdit20W and installed WINLIB5a instead of WINLIB5 and so on, but the load routine stubbornly refuses to recognise the UTF-8 encoding. Indeed, it goes so far as to add the three bytes which signal UTF-8 to the start of the text, which is not very pleasing.
Does anyone else have a solution to this, please?
Loading TEXTEDIT.BBC
-
- Posts: 78
- Joined: Sat 23 Jun 2018, 15:51
Re: Loading TEXTEDIT.BBC
Would loading WINLIB5U and reading the manual section on Unicode help?
Z
Z
-
- Posts: 327
- Joined: Wed 04 Apr 2018, 06:36
Re: Loading TEXTEDIT.BBC
Curiously, no. Changing WINLIB5A to WINLIB5U does not result in the unicode characters being loaded correctly, but it *does* cause the program to hang-up when I close down. Not sure why.
Not sure what you mean by "the manual". The BB4W help section does not appear to have a section for unicode (other than skyting about the ability to display multilingual character sets).
Incidentally, if I read the file line by line and PROCtype it in, everything displays and functions perfectly. It's just the loading that causes problems.
Thanks.
Not sure what you mean by "the manual". The BB4W help section does not appear to have a section for unicode (other than skyting about the ability to display multilingual character sets).
Incidentally, if I read the file line by line and PROCtype it in, everything displays and functions perfectly. It's just the loading that causes problems.
Thanks.
-
- Posts: 78
- Joined: Sat 23 Jun 2018, 15:51
Re: Loading TEXTEDIT.BBC
I was referring to the Help or online documentation.
WINLIB5U in Textedit.bbc works just as you would expect here.
Did you note that WINLIB5U like WINLIB5A has an additional parameter at the start? That should be the parent handle and put in @hwnd%. If you ignore that you get a 'type mismatch' error immediately.
Looking up the code of WINLIB5U you see it uses the CreateWindowExW function and that takes the parent handle which comes from this first parameter.
Perhaps that is the issue, use WINLIB5U and add the parent handle as the additional first parameter in the FN_createwindow call.
For me that allowed a load of a saved file correctly to display UTF-8 strings.
UPDATE. I can get what you see now I tried the actual welsh strings saved from Notepad with UTF-8 set.
WINLIB5U just shows the 'w' without the accent if saved and reloaded from TextEdit. The issue may be not using a font with the Celtic Encoding. Trying that string in other text editors warns me to find a font that has that accented w in it's encoding or that will be lost. So I think it might not be a BB4W issue so much as having a font that supports Welsh. If anyone has Welsh fonts installed they could prove that. Previously I had been testing on other languages that have encoding like Cyrillic where TextEdit does work. Sorry to mislead you.
Z
WINLIB5U in Textedit.bbc works just as you would expect here.
Did you note that WINLIB5U like WINLIB5A has an additional parameter at the start? That should be the parent handle and put in @hwnd%. If you ignore that you get a 'type mismatch' error immediately.
Looking up the code of WINLIB5U you see it uses the CreateWindowExW function and that takes the parent handle which comes from this first parameter.
Perhaps that is the issue, use WINLIB5U and add the parent handle as the additional first parameter in the FN_createwindow call.
For me that allowed a load of a saved file correctly to display UTF-8 strings.
UPDATE. I can get what you see now I tried the actual welsh strings saved from Notepad with UTF-8 set.
WINLIB5U just shows the 'w' without the accent if saved and reloaded from TextEdit. The issue may be not using a font with the Celtic Encoding. Trying that string in other text editors warns me to find a font that has that accented w in it's encoding or that will be lost. So I think it might not be a BB4W issue so much as having a font that supports Welsh. If anyone has Welsh fonts installed they could prove that. Previously I had been testing on other languages that have encoding like Cyrillic where TextEdit does work. Sorry to mislead you.
Z
Last edited by Zaphod on Wed 04 Jul 2018, 22:06, edited 2 times in total.
-
- Posts: 78
- Joined: Sat 23 Jun 2018, 15:51
Re: Loading TEXTEDIT.BBC
Some additional stuff.
When you were asking about Unicode on the previous forum there was a question about some of the functions not working on Unicode which I was unaware of. Anyhow, I guess it must have been raining as I wrote these library functions to fill in some of the gaps:
Code of library now moved to "Libraries" section and expanded.
UTF-8 String Functions
Below is some test code and a UTF-8 string.
Z
When you were asking about Unicode on the previous forum there was a question about some of the functions not working on Unicode which I was unaware of. Anyhow, I guess it must have been raining as I wrote these library functions to fill in some of the gaps:
Code of library now moved to "Libraries" section and expanded.
UTF-8 String Functions
Below is some test code and a UTF-8 string.
Code: Select all
VDU 23,22,640;800;8,16,16,8
*FONT Arial,16
A$=" ΒΙΒΛΟΣ γενέσεως Ἰησοῦ Χριστοῦ "
REM Test routines
PRINT A$
PRINT FN_ulen(A$)
FOR i=1 TO 10
PRINT FN_umid(A$,i,i);
PRINT FN_ulen(FN_umid(A$,i,i))
NEXT
FOR i=1 TO 10
PRINT FN_uleft(A$,i);
PRINT FN_ulen(FN_uleft(A$,i))
NEXT
FOR i=1 TO 10
PRINT FN_uright(A$,i);
PRINT FN_ulen(FN_uright(A$,i))
NEXT
TIME=0
FOR i=0 TO 100000
b$=FN_uright(A$,3)
NEXT
PRINT TIME
PRINT b$
PRINT FN_ulen(b$)
END
-
- Posts: 327
- Joined: Wed 04 Apr 2018, 06:36
Re: Loading TEXTEDIT.BBC
Thanks. I have saved your routines. They look very useful.
Thanks also for the work on loading into the text edit window. I'm sticking with PROCtype() at the moment as at least it works reliably, even if slower than the near instant loading of a proper load!
Thanks also for the work on loading into the text edit window. I'm sticking with PROCtype() at the moment as at least it works reliably, even if slower than the near instant loading of a proper load!