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

Thread: International characters in console windows

  1. #1

    International characters in console windows

    I have been trying to use local characters in some programs since I stared to use thinBasic some weeks ago. In GUI it works well but I can not find a way to get the correct characters in the Console.

    When I run a program in the Console it changes the local character map also causing all printouts to Console to be filled with garbage characters.

    Does anyone know how I can use the Console, and still keep my language?

    Exemple:
    [code=thinbasic]USES "Console"
    Console_Writeline ("Printing Swedish alfabet")
    Console_Writeline ("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
    Console_Writeline ("abcdefghijklmnopqrstuvwxyz")
    Console_WaitKey()[/code]

  2. #2
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,781
    Rep Power
    10

    Re: International characters in console windows

    Hi Jophur,

    you can use function
    [code=thinbasic]Console_SetOutputCP(<CodePage>)[/code]
    to set the codepage of the language you need.
    I'm sorry we forgot to document this function but it is simple to use. Just locate your code page and call this fucntion.

    A sample showing how to use it is: \thinBasic\SampleScripts\Console\Console_ProgressBar4.tBasicc

    Let me know if it works.
    I will document it in next thinBasic version.

    Ciao
    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  3. #3

    Re: International characters in console windows

    Thank you Eros.

    I will try this.

  4. #4

    Re: International characters in console windows

    I put this together to test all my installed Code pages
    [code=thinbasic]USES "Console"
    For i as DWORD = 0 to 100000
    Console_SetOutputCP(i)
    if i=Console_GetOutputCP() then
    Console_Write("Code page is now set to: " + i + $CRLF)
    Console_Write ("ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz" + $CRLF)
    endif
    next[/code]

    The only thing that varies are after the end of thinBasic, then the path in the console ends up in different CP's.

  5. #5
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,781
    Rep Power
    10

    Re: International characters in console windows

    Jophur,

    Code page should be setup only once at the beginning. Codepage code are not random numbers but ISO standards. See (for example) Microsoft reference at http://www.microsoft.com/globaldev/r...ce/cphome.mspx

    So, code 1257 should work for you (but I'm not sure which char set you need so I may be wrong):
    [code=thinbasic]USES "Console"

    '---Print current charset
    PrintCharSet

    '---Set new charset
    Console_SetFileApisToOEM
    Console_SetOutputCP(1257)
    PrintCharSet

    '---Finish
    printl
    printl "---Press a key to finish---------------------------------------"
    waitkey

    '---------------------------------
    function PrintCharSet() as long
    '---------------------------------
    local cCount as long

    printl "Code page is now set to: " & Console_GetOutputCP()
    printl "---Chars-------------------------------------------------------"

    for cCount = 33 to 255
    print chr$(cCount) & " "
    if mod(cCount, 32) = 0 then
    printl
    end if
    next
    printl
    end function

    [/code]

    Which Operating System are you working on? There can be great differences if you are under Win9x or Win2K or above OS.

    Thanks
    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  6. #6
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,781
    Rep Power
    10

    Re: International characters in console windows

    Ok, I found the possible problem why all chars are the same.
    TO be able to see different charsets, you need to use trutype fonts for your console output. Changing charset will not work with raster fonts.

    So, set "Lucida Console" (for example) in your Console window as default font and than execute again the script mentioned in my previous post. It should work. But again, only fro Operating systems Win2K or above because API to chane charset are not available under Win9x system.

    Ciao
    Eros

    ADDED:
    font need is mentioned in Microsoft documenation at http://msdn.microsoft.com/en-us/library/ms686036(VS.85).aspx
    Attached Images Attached Images
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  7. #7

    Re: International characters in console windows

    Hi Eros.

    I'm using WinXP SP3, Swedish version.

    this is the printout from your script:
    Code page is now set to: 850
    ---Chars-------------------------------------------------------
    ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @
    A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _ `
    a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~  
      ƒ     ˆ  Š  Œ  ˇ          ˜  š  œ  ˛ Ÿ 
             Ŗ   *             ŗ      Ą
    Į Ā Ć   Ę Ē Č  Ź Ė Ģ Ķ Ī Ļ  Ń Ņ  Ō    Ų Ł Ś Ū  Ż   ą
    į ā ć   ę ē č  ź ė ģ ķ ī ļ  ń ņ  ō    ų ł ś ū  ż  ˙
    Code page is now set to: 1257
    ---Chars-------------------------------------------------------
    ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @
    A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _ `
    a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~  
      ƒ     ˆ  Š  Œ  ˇ          ˜  š  œ  ˛ Ÿ 
             Ŗ   *             ŗ      Ą
    Į Ā Ć   Ę Ē Č  Ź Ė Ģ Ķ Ī Ļ  Ń Ņ  Ō    Ų Ł Ś Ū  Ż   ą
    į ā ć   ę ē č  ź ė ģ ķ ī ļ  ń ņ  ō    ų ł ś ū  ż  ˙
    
    ---Press a key to finish---------------------------------------
    
    E.g. same for both the 850 & 1257 Code Pages... I can not see any update inside thinbasic, the only change I've seen so far is after thinBasic has completed the script end ended. Then is the Code Page updated inside the console. I will try see what I can get for results if I try to do the same in Open Watcom.

    To print the letter "" I need to use chr$(142), this when it really is chr$(196) in both Code Page 850, 1257. I can not see any change in any of the 55 Code pages I have installed on my machine...

    Could you try to see what result you get on that script?

  8. #8
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,781
    Rep Power
    10

    Re: International characters in console windows

    Jophur,

    maybe we were posting at the same time.
    Can you see my previous post about changing Console font to a TrueType one and check again.
    Attached a screenshot of my example working with a TT font.

    Let me know.
    Ciao
    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  9. #9

    Re: International characters in console windows

    Thank you Eros,

    TrueType was the answer!

  10. #10
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,781
    Rep Power
    10

    Re: International characters in console windows

    OK, perfect.

    I'm checking if there is a programmatic way to change font in Console window but so far I'm not found any. Microsoft documenation seems not having a ...SetFont... function: http://msdn.microsoft.com/en-us/library/ms682073(VS.85).aspx

    I will check in some ASM forums. Maybe there is a low level way.

    Ciao
    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

Page 1 of 2 12 LastLast

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

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