Page 1 of 2 12 LastLast
Results 1 to 10 of 20

Thread: Does ThinAir supports Unicode ?

  1. #1

    Does ThinAir supports Unicode ?

    Hi all,
    Thanks for this nice IDE and nice language. It doesn't deems to be support unicode. When i type some texts in my native language (Malayalam - India), it shows some question marks. Normaly, this type ide's have an option set the encoding to UTF-8 or something like that. I can't find one in ThinAir. Did i miss something ?

  2. #2
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    6,778
    Blog Entries
    3
    Rep Power
    691
    Hi,

    thinBasic unicode support is an area which could be expanded a lot.

    But to give you a start, have a look at the following functions to see, if their help you achieve what you need:
    • IsUnicode
    • Ascii2Unicode
    • Unicode2Ascii
    • WideCharToUTF8$
    • UTF8ToWideChar$
    • UTF8ToAnsi$
    • AnsiToUTF8$


    I remember talking with Eros regarding UTF8. I think thinAir does not support it in current build, but thinBasic interpreter can use UTF8 files to execute.

    Regarding code page in console, I think the following function is very helpful:


    • Console_SetCP


    You can check the information about these in Help file, which you can launch by pressing F1 key in thinAir.


    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 7 64bit - Intel Core 2 Duo T6600 @ 2.2GHz - 4 GB RAM - NVIDIA GeForce G210M 512MB
    Windows 8 64bit - Intel Core i5-3350P @ 3.1GHz - 8 GB RAM - NVIDIA GeForce GT640 3GB

  3. #3
    @Petr Schreiber,
    Thanks. Let me try

  4. #4
    Hi,
    I have tried all functions you said in above post. None of them are worked. Feeling sad about unicode.

  5. #5
    Hi kcvinu
    i am curious if this approach works:
    use notepad to save this code:

    Uses "UI"

    string a
    a = "മലയാളം"
    msgbox 0,a


    to the thinbasic folder, then from command prompt write
    thinBasicc test.txt
    does it display the മലയാളം correctly on your system ? if not try the functions listed by Petr with the മലയാളം in notepad and try again.
    i have tried the Greek and several other languages and it is displayed correctly in the thinAir ide and in the msgbox, except the indian(
    Malayalam) . but don't despair, you can request the proper management of your language here http://www.thinbasic.com/community/p...hp?projectid=1 . Eros in a holiday (in a remote island with no internet connection) for 2 weeks.

  6. #6
    @primo
    Thanks for your reply. But your aproach didn't worked for me. The msgbox showed with strange symbols.

  7. #7
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    6,778
    Blog Entries
    3
    Rep Power
    691
    It is often the case to store the string literals in some kind of string table, separate from the main program.
    In the program, you then reference the literals by names.

    Cookbook
    - create a data file with strings, for example in format:
    programName,"Čučoriedka"
    okButton,"Tak třeba j"
    cancelButton,"Tak sp teda n"
    - create a wrapper user defined type to handle the loading and referencing
    - use wrapper user defined type in your program


    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 7 64bit - Intel Core 2 Duo T6600 @ 2.2GHz - 4 GB RAM - NVIDIA GeForce G210M 512MB
    Windows 8 64bit - Intel Core i5-3350P @ 3.1GHz - 8 GB RAM - NVIDIA GeForce GT640 3GB

  8. #8
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    50
    Posts
    8,128
    Blog Entries
    2
    Rep Power
    10
    Unicode is still a problem for thinBasic.
    Most of the API functions thinBasic uses are Ascii version and not Wide version.

    I will see what I can do in next thinBasic versions on this side.
    www.thinbasic.com | www.thinbasic.com/community/ | psch.thinbasic.com
    Win10Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

  9. #9
    @Petr - That's a nice workaround to try. Thanks.
    @eros - I will be happy if i can do some coding in thinBasic with unicode support. I like to see my programs show my native language.

  10. #10

    Using Unicode in some controls

    Saluton, ĉiuj // Hello, everyone,

    Just in case somebody kcvinu, for instance is still interested in how Unicode can be used with ThinBASIC: there is a small example below.

    A very short summary:
    in order to display Unicode correctly in buttons and messageboxes we can use
    (a) the functions Petr kindly indicated above, i. e. UTF8ToWideChar$ and others; actually, for my programme UTF8ToWideChar$ was sufficient (the encoding was UTF-8 throughout);
    (b) WinAPI functions, Unicode versions (their declarations are in the text of the programme): SendMessageW, SetWindowTextW, MessageBoxW.

    Strings are declared as AsciiZ, specified in the programme directly (UTF-8) and converted to WideChar, then pointed to by ThinBASIC's STRPTR().

    '
    ' =======================================
    '  FASADO. Provo uzi kodoprezenton UTF-8
    ' =======================================
    '
    
    uses "UI"
    
    declare function SendMessageW lib "user32.dll" _
              alias "SendMessageW" _
             (ByVal t as DWord, ByVal m as DWord, _
              ByVal wp as DWord, ByVal adrL as Long) _
            as Long
    declare function SetWindowTextW lib "user32.dll" _
              alias "SetWindowTextW" _
             (ByVal t as DWord, ByVal adrL as Long) _
            as Long
    declare function MessageBoxW lib "user32.dll" _
              alias "MessageBoxW" _
             (ByVal t as DWord, ByVal adrLt as Long, _
              ByVal adrLcx as Long, ByVal n as DWord) _
            as Long
    
    Begin ControlID 
      %butEn
      %butEo
      %butRu
      %butFa
      %butKr
      %butYi
      %butAr
      %butHi
      %butJa
      %knvP
    End ControlID
    
    %UTF8 = 65001
    %DlgL = 600
    %DlgAt = 300
    %DlgA = 400
    %CxL = %DlgL \ 3
    %CxA = %DlgAt \ 3
    %d = 10
    %bL = %CxL - %d - %d
    %bA = %CxA - %d - %d
    %LtrA = 12
    
    $Ttl = "Unicode-text buttons; each changes the colour of the canvas below."
    $nButEn = "Well... Close!"
    $LtrN = "Arial Unicode MS"
    
    dim DlgH, DlgV, r as Long
    dim tDlg, _
        tButEo, tButRu, tButFa, tButKr, tButYi, tButAr, tButHi, tButJa, tKnv _
    as DWord
    dim nButEo, nButRu, nButFa, nButKr, nButYi, nButAr, nButHi, nButJa, _
        mFaCx, mFaT _
    as AsciiZ
    
    ' ================
    '  CXEFA PROGRAMO
    ' ================
    
    	FUNCTION TbMain()
    
    nButEo = "Ŝanĝiĝu... Ĝis!"
    nButRu = "Что ж, закроем!"
    nButFa = "!ﺪﯿﻨﻜﺑ ﻪﺘﺴﺑ"
    nButKr = "창문을 닫기!"
    nButYi = "!ןכאַמוצ רעטצנעפֿ"
    nButAr = "Պատուհան փակել"
    nButHi = "खिड़की बंद करे ।"
    nButJa = "まど を 閉じる。"
    
    mFaCx = UTF8ToWideChar$("Ĉapo de mesaĝ-panelo:")
    mFaT = UTF8ToWideChar$(nButRu & $CRLF & nButFa)
    
    desktop get client to DlgH, DlgV
    DlgH = (DlgH - %DlgL) \ 2: DlgV = (DlgV - %DlgA) \ 2
    
    dialog font $LtrN, %LtrA
    
    tDlg = Dialog_New (Pixels, 0, $Ttl, _
                       DlgH, DlgV, %DlgL, %DlgA, _
                       %WS_DLGFRAME          | _
                       %WS_CAPTION           | _
                       %WS_SYSMENU           | _
                       %WS_OVERLAPPEDWINDOW  , 0)
    
    dialog set client tDlg, %DlgL, %DlgA
    
    control add button, tDlg, %butEn, $nButEn, %d, %d, %bL, %bA
    
    control add button, tDlg, %butEo, $SPC, %d+%CxL, %d, %bL, %bA
    control handle tDlg, %butEo to tButEo
    nButEo = UTF8ToWideChar$(nButEo)
    SendMessageW (tButEo, 12, 0, strptr(nButEo))
    
    control add button, tDlg, %butRu, $SPC, %d+%CxL+%CxL, %d, %bL, %bA
    control handle tDlg, %butRu to tButRu
    nButRu = UTF8ToWideChar$(nButRu)
    SendMessageW (tButRu, 12, 0, strptr(nButRu))
    
    control add button, tDlg, %butFa, $SPC, %d, %d+%CxA, %bL, %bA
    control handle tDlg, %butFa to tButFa
    nButFa = UTF8ToWideChar$(nButFa)
    ' SendMessageW (tButFa, 12, 0, strptr(nButFa))
    SetWindowTextW (tButFa, strptr(nButFa))
    
    control add button, tDlg, %butKr, $SPC, %d+%CxL, %d+%CxA, %bL, %bA
    control handle tDlg, %butKr to tButKr
    nButKr = UTF8ToWideChar$(nButKr)
    SendMessageW (tButKr, 12, 0, strptr(nButKr))
    
    control add button, tDlg, %butYi, $SPC, %d+%CxL+%CxL, %d+%CxA, %bL, %bA
    control handle tDlg, %butYi to tButYi
    nButYi = UTF8ToWideChar$(nButYi)
    SendMessageW (tButYi, 12, 0, strptr(nButYi))
    
    control add button, tDlg, %butAr, $SPC, %d, %d+%CxA+%CxA, %bL, %bA
    control handle tDlg, %butAr to tButAr
    nButAr = UTF8ToWideChar$(nButAr)
    SendMessageW (tButAr, 12, 0, strptr(nButAr))
    
    control add button, tDlg, %butHi, $SPC, %d+%CxL, %d+%CxA+%CxA, %bL, %bA
    control handle tDlg, %butHi to tButHi
    nButHi = UTF8ToWideChar$(nButHi)
    SendMessageW (tButHi, 12, 0, strptr(nButHi))
    
    control add button, tDlg, %butJa, $SPC, %d+%CxL+%CxL, %d+%CxA+%CxA, %bL, %bA
    control handle tDlg, %butJa to tButJa
    nButJa = UTF8ToWideChar$(nButJa)
    SendMessageW (tButJa, 12, 0, strptr(nButJa))
    
    tKnv = control add canvas, tDlg, %knvP, "", _
           %d, %d+%CxA+%CxA+%CxA, %DlgL - %d - %d, %bA, , %WS_EX_STATICEDGE
    Canvas_Attach (tDlg, %knvP, %FALSE)
    Canvas_Clear (%RGB_BLACK)
    
    dialog show modal tDlg, call trFENESTRO
    
    	END FUNCTION
    
    ' =========================
    '  PROCEDUROJ KAJ FUNKCIOJ
    ' =========================
    
    	Callback Function trFENESTRO() as Long
      
    SELECT CASE cbMsg
    
      CASE %WM_COMMAND
    
        select case cbCtl
                    
          case %butEn
            if cbCtlMsg = %BN_CLICKED then Canvas_Clear (%RGB_BLUE)
    
          case %butEo
            if cbCtlMsg = %BN_CLICKED then Canvas_Clear (%RGB_RED)
    
          case %butRu
            if cbCtlMsg = %BN_CLICKED then
              Canvas_Clear (%RGB_GREEN)
              MsgBox (tDlg, "=m=", %MB_OK, "=t=")
            end if
    
          case %butFa
            if cbCtlMsg = %BN_CLICKED then
              Canvas_Clear (%RGB_CYAN)
              MessageBoxW (tDlg, strptr(mFaT), strptr(mFaCx), %MB_OK)
            end if
    
          case %butKr
            if cbCtlMsg = %BN_CLICKED then Canvas_Clear (%RGB_MAGENTA)
    
          case %butYi
            if cbCtlMsg = %BN_CLICKED then Canvas_Clear (%RGB_YELLOW)
    
          case %butAr
            if cbCtlMsg = %BN_CLICKED then Canvas_Clear (%RGB_BROWN)
    
          case %butHi
            if cbCtlMsg = %BN_CLICKED then Canvas_Clear (%RGB_GRAY)
    
          case %butJa
            if cbCtlMsg = %BN_CLICKED then Canvas_Clear (%RGB_POWDERBLUE)
    
        end select
    
    END SELECT
      
    	End Function
    
    Ĝis // Regards,
    Uzulo

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 6
    Last Post: 15-03-2014, 21:32
  2. 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
  3. Proposed Wide String (Unicode) support in OxygenBasic
    By Charles Pegge in forum O2h Compiler
    Replies: 2
    Last Post: 27-02-2011, 04:08
  4. Is this ASCII, ANSI, UNICODE or something else?
    By martin in forum thinAir General
    Replies: 12
    Last Post: 29-04-2009, 09:56

Posting Permissions

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