Results 1 to 9 of 9

Thread: need a Unicode working example

  1. #1

    Question need a Unicode working example

    I am new to thinBasic (and programming in general). I need to know how to display a string of foreign characters (such as Greek or Russian) in a simple text field or message box. I have looked through this forum and I found mostly excuses for why thinBasic can't handle Unicode. However "Uzulo" has posted a good working solution. It requires running as "thinbasicc test.txt" to actually work, but that is okay since nothing else on this forum works for Unicode.

    https://www.thinbasic.com/community/...3079#post93079

    The only problem is that Uzulo complicated his code by adding boxes, colors, and other bells and whistles that confuse a newbie like me. I want to only display a string of foreign characters. Period. I need that snippet of code. What do I extract from Uzulo's code without breaking it? I can only learn from working examples that I may modify. Memorizing code rules or lengthy syntax does not really work for me (or for Rapid Application Development). Thanks.

  2. #2
    Quote Originally Posted by fkapnist View Post
    I need to know how to display a string of foreign characters (such as Greek or Russian) in a simple text field or message box.
    Hi fkapnist,
    and welcome !

    This code works for me :

    Dim nButEo = "Ŝanĝiĝu... Ĝis!"
    Dim nButRu = "Что ж, закроем!"
    Dim nButFa = "!ﺪﯿﻨﻜﺑ ﻪﺘﺴﺑ"
    Dim nButKr = "창문을 닫기!"
    Dim nButYi = "!ןכאַמוצ רעטצנעפֿ"
    Dim nButAr = "Պատուհան փակել"
    Dim nButHi = "खिड़की बंद करे ।"
    Dim nButJa = "まど を 閉じる。"
    
    MsgBoxW (0,nButEo)
    MsgBoxW (0,nButRu)
    MsgBoxW (0,nButFa)
    MsgBoxW (0,nButKr)
    MsgBoxW (0,nButYi)
    MsgBoxW (0,nButAr)
    MsgBoxW (0,nButHi)
    MsgBoxW (0,nButJa)
    
    help page is here : https://www.thinbasic.com/public/pro...ml/msgboxw.htm
    ThinBasic 1.11.6.0 ALPHA - Windows 8.1 x64

  3. #3

    Unknown Keyword

    Thank you. I am an absolute beginner. When I run the code as it is, I get: " Unknown Keyword MSGBOXW " So I went to the help file you link to and searched for "Keyword." But I got "thinBasic_GetKeywordSpeficic" which I think is a misspelling and it shows nothing but a blank page. In programming it seems that the easiest things are often the hardest, and the hardest are achieved by accident...




    Quote Originally Posted by DirectuX View Post
    Hi fkapnist,
    and welcome !

    This code works for me :

    Dim nButEo = "Ŝanĝiĝu... Ĝis!"
    Dim nButRu = "Что ж, закроем!"
    Dim nButFa = "!ﺪﯿﻨﻜﺑ ﻪﺘﺴﺑ"
    Dim nButKr = "창문을 닫기!"
    Dim nButYi = "!ןכאַמוצ רעטצנעפֿ"
    Dim nButAr = "Պատուհան փակել"
    Dim nButHi = "खिड़की बंद करे ।"
    Dim nButJa = "まど を 閉じる。"
    
    MsgBoxW (0,nButEo)
    MsgBoxW (0,nButRu)
    MsgBoxW (0,nButFa)
    MsgBoxW (0,nButKr)
    MsgBoxW (0,nButYi)
    MsgBoxW (0,nButAr)
    MsgBoxW (0,nButHi)
    MsgBoxW (0,nButJa)
    
    help page is here : https://www.thinbasic.com/public/pro...ml/msgboxw.htm

  4. #4
    To be specific, I want to use this example file:

    DIM RetCode AS LONG
    DIM tOut1   AS LONG = 10
    DIM tOut2   AS LONG =  5
    DIM Msg     AS STRING
    
    Msg = "Hi everybody." & $crlf & _
          "This message will be on screen for " & tOut1 & " seconds." & $CRLF & _
          "Your can click on this message or wait for timeout." & $CRLF & _
          "Different return codes will be generated for different actions"
          
    RetCode = Alert("thinBasic Alert", Msg, tOut1)
    
    Alert("thinBasic RetCode", "Alert returned " & RetCode, tOut2)
    
    But I want to replace the Latin characters with Greek for example:

    DIM RetCode AS LONG
    DIM tOut1   AS LONG = 10
    DIM tOut2   AS LONG =  5
    DIM Msg     AS STRING
    
    Msg = "Γειά σου πώς είσαι." & $crlf & _
          "This message will be on screen for " & tOut1 & " seconds." & $CRLF & _
          "Πιέστε το μενού ή κάντε κλικ στο μήνυμα αυτό." & $CRLF & _
          "Different return codes will be generated for different actions"
          
    RetCode = Alert("thinBasic Alert", Msg, tOut1)
    
    Alert("thinBasic RetCode", "Alert returned " & RetCode, tOut2)
    
    What is needed to display the correct language characters?


  5. #5
    Quote Originally Posted by fkapnist View Post
    When I run the code as it is, I get: " Unknown Keyword MSGBOXW "
    which version of ThinBasic do you use ?
    I ran the code with this preview version : https://www.thinbasic.biz/projects/t...c_1.10.6.0.zip

    Quote Originally Posted by fkapnist View Post
    I went to the help file you link to and searched for "Keyword."
    it is a direct link to the MSGBOXW man page, you don't need to make a search. If you want to search it , search MSGBOXW instead of Keyword
    Also thinBasic_GetKeywordSpeficic has a blank page for me too.
    Last edited by DirectuX; 26-11-2018 at 19:24.
    ThinBasic 1.11.6.0 ALPHA - Windows 8.1 x64

  6. #6
    Quote Originally Posted by fkapnist View Post
    What is needed to display the correct language characters?
    I don't know other answer than the previous msgboxw

    Quote Originally Posted by fkapnist View Post
          
    RetCode = Alert("thinBasic Alert", Msg, tOut1)
    
    Alert("thinBasic RetCode", "Alert returned " & RetCode, tOut2)
    
    The Alert keyword is not described as an utf8-aware function. To the extent of my (weak) knowledge I think it will not do the job as you want. That is maybe why in this post https://www.thinbasic.com/community/...3079#post93079 the script declares windows functions to do this.
    ThinBasic 1.11.6.0 ALPHA - Windows 8.1 x64

  7. #7
    I managed to get this

    Capture.PNG

    with this code:

    '---Script created on 11-26-2018 18:28:52 by 
    DIM RetCode AS LONG
    DIM tOut1   AS LONG = 10
    DIM tOut2   AS LONG =  5
    DIM Msg     AS STRING
     
    Msg = "ĥ꜠󯵠𾲠栳⩮"
           
    Alert("thinBasic Alert", Msg, tOut1)
    
    I think ThinAir saves script file in utf8.
    I pre-converted the string to ansi, it's why it displays weird in thinAir. Curiously, in my trying utf8toans$() does not the job.

    script file : unicode2.zip
    Last edited by DirectuX; 26-11-2018 at 20:31. Reason: script upload
    ThinBasic 1.11.6.0 ALPHA - Windows 8.1 x64

  8. #8
    I upgraded to version 10.6 of thinBasic. In \SampleScripts\UI\RichEdit\ I found that RichEdit_002.tBasic (TinyWord - RichEdit sample) has full Unicode support with a large selection of fonts. Ui\Sdk\ DIALOG_UNICODE.tbasic will display foreign language characters.


    This works in version 10

    Dim nButEo = "Ŝanĝiĝu... Ĝis!"
    Dim nButRu = "Что ж, закроем!"
    Dim nButFa = "!ﺪﯿﻨﻜﺑ ﻪﺘﺴﺑ"
    Dim nButKr = "창문을 닫기!"
    Dim nButYi = "!ןכאַמוצ רעטצנעפֿ"
    Dim nButAr = "Պատուհան փակել"
    Dim nButHi = "खिड़की बंद करे ।"
    Dim nButJa = "まど を 閉じる。"
     
    MsgBoxW (0,nButEo)
    MsgBoxW (0,nButRu)
    MsgBoxW (0,nButFa)
    MsgBoxW (0,nButKr)
    MsgBoxW (0,nButYi)
    MsgBoxW (0,nButAr)
    MsgBoxW (0,nButHi)
    MsgBoxW (0,nButJa)
    
    I tried pre-saving the alert message with ANSI encoding as you did. It worked okay for Greek but Russian came out ????????.... I have Greek installed as a second language in my Windows PC.
    Last edited by fkapnist; 27-11-2018 at 02:05.

  9. #9
    Quote Originally Posted by fkapnist View Post
    It worked okay for Greek but Russian came out ????????.... I have Greek installed as a second language in my Windows PC.
    I confirm here all languages printed out ok.
    *maybe* (it's a guess of what I would check) :
    your default font don't support russian
    or
    you have to add russian in control panel \ languages
    or
    you have to select russian in control panel \ region \ administration

    Quote Originally Posted by fkapnist View Post
    RichEdit_002.tBasic (TinyWord - RichEdit sample) has full Unicode support with a large selection of fonts. Ui\Sdk\ DIALOG_UNICODE.tbasic will display foreign language characters.
    Nice, you've got you solution !?
    ThinBasic 1.11.6.0 ALPHA - Windows 8.1 x64

Similar Threads

  1. put unicode chars on a button
    By primo in forum thinBasic General
    Replies: 3
    Last Post: 20-08-2017, 02:11
  2. File names in a unicode world
    By harsh in forum File
    Replies: 0
    Last Post: 01-02-2017, 03:27
  3. Does ThinAir supports Unicode ?
    By kcvinu in forum thinAir General
    Replies: 19
    Last Post: 29-08-2016, 14:57
  4. HELP FILE : Unicode information swapped
    By Michael Clease in forum Fixed or cleared errors in help material
    Replies: 1
    Last Post: 09-03-2011, 12:19
  5. Is this ASCII, ANSI, UNICODE or something else?
    By martin in forum thinAir General
    Replies: 12
    Last Post: 29-04-2009, 09:56

Members who have read this thread: 0

There are no members to list at the moment.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •