Jump to content

Nihongo - Japanese with AutoIT


charvi
 Share

Recommended Posts

Hi everybody,

Today I'm beginning with using Japanese in my programs. This means that we need to use UTF-8 and the computer needs a Japanese font like "MS Mincho" or "MS Gothic".

Creating labels, buttons, inputs with Japanese contents is perfectly supported, but how to use it within SciTe? How to change the base font in Scite to MS Gothic for example?

So far, to avoid garbage like "?????" I must write code this way:

$s = chrw(0x65e5)&chrw(0x672c)&chrw(0x8a9e)

so the variable $s contains "日本語" (here in the forum it works very well!!)

Any suggestion is welcome.

Cheers, Charvi

Link to comment
Share on other sites

Thats wierd, I can use it perfectly well with Korean.

while 1
    $s = "메롱."
    MsgBox(0, "", "try : " & $s)
WEnd

Or maybe that's not what ur looking for?

@geasiki

Yes geasiki, that's what I'm looking for. I suppose that you have at the right side of the Windows taskbar a square with KR for Korean, and then you type in Korean. Can you type directly in Korean in Scite? Did you change some parameters in Scite? Are you using an English Windows system?

@Zedna

Thank you for pointing to the file SciTEGlobal.properties

I have changed to code.page=65001 and SciTe is working as expected, but when the program is run, is shows garbage. It should be Unicode, not ShiftJis. Which standard Windows font uses Unicode?

Code fragment in SciTE:

Global $gs_Company = "日本の会社の名前"

This will show garbage in a simple GUICtrlCreateLabel() using font "MS Gothic".

Are the *.TTC fonts Unicode fonts?

Edited by charvi
Link to comment
Share on other sites

  • Developers

Ah... perhaps that's the reason. It's checked on "Code Page Property". Shoud I change it to UTF-8 or UTF-8 with BOM ? And what does BOM mean?

Thanks Jos

Either way should work.

One thing thats good to know is that the following programs will not work with Uncode files: Au3check, Tidy and Obfuscator.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Actually I'm using English Vista and I have only one keyboard setting, Korean.

I didn't change any settings in Scite.

Weird because the script shows perfectly...

Global $gs_Company = "日本の?社の名前"

while 1
    MsgBox(0, "", "is = " & $gs_Company)
    WEnd

I type Korean directly in Scrite...

Oh, try this.

Control panels -> Regional and Language Options -> Administrative -> Change System Locale to Japenes.

It's where u can change the language for non-unicode programs.

Edited by geasiki
Link to comment
Share on other sites

  • Developers

It normally should detect the codepage settings which is the default setting in the option I mentioned.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

It normally should detect the codepage settings which is the default setting in the option I mentioned.

Jos

Hmm, still not working... (see picture)

I'm also using Vista (Home Premium) English version, with ability to use Japanese when I click on JP in the small square.

I'm certainly still missing something, but what???

In the SciTEGlobal.properties file Zedna told me, the "code.page=65001" and "character.set=0"

The SciTE's File/Encoding/ is set to "UTF-8 with BOM"

The font used to the GUICtrlCreateLabel() in the attach is "MS Gothic" (msgothic.ttc)

Posted Image

post-39937-1233086478_thumb.jpg

Link to comment
Share on other sites

  • Developers

What vesion of autoit3 are you running?

Maybe show the SciTE output pane information when doing an F5 (run) ?

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

What vesion of autoit3 are you running?

Maybe show the SciTE output pane information when doing an F5 (run) ?

Jos

Using AutoIT 3.3.0.0

There is no error message, just warnings for variables that are possibly used before declaration, but these are okay.

In the Console window we read this when launched:

>"C:\APPS\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\APPS\AU3\MLSAU\MLSAU.au3" /autoit3dir "C:\APPS\AutoIt3" /UserParams

+>21:30:49 Starting AutoIt3Wrapper v.1.10.1.14 Environment(Language:0409 Keyboard:0000080C OS:WIN_VISTA/Service Pack 1 CPU:X86 ANSI)

>Running AU3Check (1.54.14.0) from:C:\APPS\AutoIt3

Link to comment
Share on other sites

  • Developers

I am pretty sure you haven't show all here.

Also expect AutoIt3wrapper to show a warning about the input file being UTF8 and not running au3check

Something like:

+>21:40:56 Starting AutoIt3Wrapper v.1.10.1.14  Environment(Language:0409  Keyboard:00020409  OS:WIN_XP/Service Pack 3  CPU:X86  ANSI)
! ***************************************************************************************************
! * Input file is UTF8 encoded with BOM, Au3Check does not support UNICODE and will be skipped.  *
! ***************************************************************************************************
>Running:(3.3.0.0):C:\Program Files\AutoIt3\autoit3.exe "C:\OpenInScite82.au3"  
>Error code: 0
+>21:40:57 AutoIT3.exe ended.rc:0
+>21:40:58 AutoIt3Wrapper Finished
>Exit code: 0   Time: 2.349

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

This is the complete listing of the Console window from start program to end program

>"C:\APPS\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\APPS\AU3\MLSAU\MLSAU.au3" /autoit3dir "C:\APPS\AutoIt3" /UserParams  
+>21:48:05 Starting AutoIt3Wrapper v.1.10.1.14  Environment(Language:0409  Keyboard:0000080C  OS:WIN_VISTA/Service Pack 1  CPU:X86  ANSI)
>Running AU3Check (1.54.14.0)  from:C:\APPS\AutoIt3
C:\APPS\AU3\MLSAU\_Login_.au3(103,39) : WARNING: $h_WinMainTitle: possibly used before declaration.
    GUISetState(@SW_SHOW, $h_WinMainTitle)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\APPS\AU3\MLSAU\_Login_.au3(104,34) : WARNING: $h_WinMain: possibly used before declaration.
    GUISetState(@SW_SHOW, $h_WinMain)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\APPS\AU3\MLSAU\_Login_.au3(111,34) : WARNING: $h_Login_Pen: possibly used before declaration.
    _GDIPlus_PenDispose($h_Login_Pen)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\APPS\AU3\MLSAU\_UsersSetup_.au3(103,39) : WARNING: $h_UsersSetup_Pen: possibly used before declaration.
    _GDIPlus_PenDispose($h_UsersSetup_Pen)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\APPS\AU3\MLSAU\_UsersSetup_.au3(215,64) : WARNING: $h_Debug: possibly used before declaration.
            Case $ai_Msg[0] = $GUI_EVENT_CLOSE And $ai_Msg[1] = $h_Debug
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\APPS\AU3\MLSAU\_WM_PAINT_.au3(21,66) : WARNING: $h_MLSAU_VistaLogoImage: possibly used before declaration.
    _GDIPlus_GraphicsDrawImage($h_MLSAU_Hdc, $h_MLSAU_VistaLogoImage,
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\APPS\AU3\MLSAU\_WM_PAINT_.au3(26,56) : WARNING: $i_Login_Color: possibly used before declaration.
            _GDIPlus_PenSetColor($h_Login_Pen, $i_Login_Color[0])
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\APPS\AU3\MLSAU\_WM_PAINT_.au3(27,58) : WARNING: $i_Login_X1: possibly used before declaration.
            _GDIPlus_GraphicsDrawLine($h_Login_Hdc, $i_Login_X1[0],
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\APPS\AU3\MLSAU\_WM_PAINT_.au3(27,74) : WARNING: $i_Login_Y1: possibly used before declaration.
            _GDIPlus_GraphicsDrawLine($h_Login_Hdc, $i_Login_X1[0], $i_Login_Y1[0],
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\APPS\AU3\MLSAU\_WM_PAINT_.au3(27,90) : WARNING: $i_Login_X2: possibly used before declaration.
            _GDIPlus_GraphicsDrawLine($h_Login_Hdc, $i_Login_X1[0], $i_Login_Y1[0], $i_Login_X2[0],
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\APPS\AU3\MLSAU\_WM_PAINT_.au3(27,106) : WARNING: $i_Login_Y2: possibly used before declaration.
            _GDIPlus_GraphicsDrawLine($h_Login_Hdc, $i_Login_X1[0], $i_Login_Y1[0], $i_Login_X2[0], $i_Login_Y2[0],
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

~~~~~~~^
C:\APPS\AU3\MLSAU\_WM_PAINT_.au3(56,57) : WARNING: $h_DT_Image: possibly used before declaration.
            _GDIPlus_GraphicsDrawImageRect($h_DT_Hdc, $h_DT_Image,
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\APPS\AU3\MLSAU\MLSAU.au3(498,24) : WARNING: $s_Before: possibly used before declaration.
    If $s_Now = $s_Before Then
    ~~~~~~~~~~~~~~~~~~~~~~^
C:\APPS\AU3\MLSAU\MLSAU.au3(499,29) : WARNING: $h_DosPrint1: possibly used before declaration.
    GUICtrlSetData($h_DosPrint1,
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\APPS\AU3\MLSAU\MLSAU.au3(500,29) : WARNING: $h_DosPrint2: possibly used before declaration.
    GUICtrlSetData($h_DosPrint2,
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\APPS\AU3\MLSAU\MLSAU.au3(501,29) : WARNING: $h_DosPrint3: possibly used before declaration.
    GUICtrlSetData($h_DosPrint3,
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\APPS\AU3\MLSAU\_Func_.au3(464,17) : WARNING: $h_Debug: declared global in function only. Prefer top of file.
    Global $h_Debug,
    ~~~~~~~~~~~~~~~^
C:\APPS\AU3\MLSAU\MLSAU.au3 - 0 error(s), 17 warning(s)
->21:48:06 AU3Check ended.rc:1
>Running:(3.3.0.0):C:\APPS\AutoIt3\autoit3.exe "C:\APPS\AU3\MLSAU\MLSAU.au3"    
+>21:48:09 AutoIT3.exe ended.rc:0
+>21:48:10 AutoIt3Wrapper Finished
>Exit code: 0   Time: 5.898

I have many include programs - I suppose they are all running in UNICODE mode when set in UTF-8 with BOM?

I remember once while testing to have seen the message "Input file is UTF8 encoded with BOM, Au3Check does not support UNICODE and will be skipped." around asterisks, but this is not happening now, and I think I saw this message during AutoIt 3.2....

Jos, as you are a developer, and if you need to, I can send you the package in a ZIP file to your private e-mail, please let me know your address then.

Link to comment
Share on other sites

  • Developers

Jos, as you are a developer, and if you need to, I can send you the package in a ZIP file to your private e-mail, please let me know your address then.

No need to. Looks like you are running the correct releases of software but the original script you use is likely not UTF8+BOM or else you would have had the warning and au3check for sure would have failed as it doesn't support UNICODE files.

So first thing to check is to get you source files saved correctly. chech the encoding again and make sure it is set correctly. if so make a small change and save the file. Then try running it again.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

No need to. Looks like you are running the correct releases of software but the original script you use is likely not UTF8+BOM or else you would have had the warning and au3check for sure would have failed as it doesn't support UNICODE files.

So first thing to check is to get you source files saved correctly. chech the encoding again and make sure it is set correctly. if so make a small change and save the file. Then try running it again.

Jos

Ah, I have discovered something, thanks to your answer. I copied the line containing the Japanese text to the main program:

Local $gs_Company = "日本の会社の名前"

and the red asterisks

! ***************************************************************************************************

! * Input file is UTF8 encoded with BOM, Au3Check does not support UNICODE and will be skipped. *

! ***************************************************************************************************

is now showing when run. The variable $gs_Company was declared in an #include, hence it was not detected and the Au3Check ran anyway.

But the title on blue background is still garbage. I'm now going to check that step by step.

Charvi

Link to comment
Share on other sites

Ah, I have discovered something, thanks to your answer. I copied the line containing the Japanese text to the main program:

Local $gs_Company = "日本の会社の名前"

and the red asterisks

! ***************************************************************************************************

! * Input file is UTF8 encoded with BOM, Au3Check does not support UNICODE and will be skipped. *

! ***************************************************************************************************

is now showing when run. The variable $gs_Company was declared in an #include, hence it was not detected and the Au3Check ran anyway.

But the title on blue background is still garbage. I'm now going to check that step by step.

Charvi

Jos, it is very strange. I made a simplified version with Japanese, ran it with UTF8 and didn't worked (garbage). I then copied a line to another place, and ran it again and surprise, it worked well. Perplexed, I removed the copied line and it still works!!! And I cannot reset to the not-working state!

In the not-simplified program, I am totally unable to get the Japanese characters in the title bar, and the the warning for Au3Check is no longer displayed. It looks like as the automatic checker not being 100% fool-proof.... Is there a way to force a Unicode compilation programmatically? (with an #AutoItWrapper?)

Does this simplified version work on your computer?

#include <Array.au3>
#include <ButtonConstants.au3>
#include <Color.au3>
#include <Constants.au3>
#include <Date.au3>
#include <DateTimeConstants.au3>
#include <EditConstants.au3>
#include <File.au3>
#include <GDIPlus.au3>
#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <GuiMenu.au3>
#include <GuiStatusBar.au3>
#include <GuiToolBar.au3>
#include <INet.au3>
#include <Math.au3>
#include <Memory.au3>
#include <Misc.au3>
#include <StaticConstants.au3>
#include <String.au3>
#include <Timers.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>

GUICreate("Test", 800, 640)

Local $i_Msg
Global Const $cs_JpnFontName = "MS Gothic"
Global Const $cn_JpnFontSize = 14
Global Const $ci_JpnFontW = 18
Global Const $ci_JpnFontH = 20


GUISetFont(16,400,1,"MS Gothic")


Local $h01 = GUICtrlCreateInput("",  10, 110,  200, 25)
Local $h02 = GUICtrlCreateInput("",  10, 140,  200, 25)
Local $h03 = GUICtrlCreateInput("",  10, 170,  200, 25)
Local $h04 = GUICtrlCreateInput("",  10, 200,  200, 25)
Local $h05 = GUICtrlCreateInput("",  10, 230,  200, 25)
Local $nihongo="大丈夫"
Local $gs_Company = "日本の会社の名前"
_Print_($gs_Company, 10, 10, -1, -1, 2, -2, 0x000000, $cs_JpnFontName, $cn_JpnFontSize, 1, 400)

GUICtrlCreateButton($nihongo, 400,200,100,30)
GUISetState()

    While 1
        $i_Msg = GUIGetMsg()
        Select
            Case $i_Msg = $GUI_EVENT_CLOSE
                ExitLoop
        ;EndCase
        EndSelect
    WEnd
    
Func _Print_($s_Var, $i_X, $i_Y, $i_W = -1, $i_H = -1, $i_Align = 0, $i_BkColor = -2, $i_Color = 0x000000, $s_FontName = $cs_JpnFontName, $n_FontSize = $cn_JpnFontSize, $i_FontAttr = 1, $i_FontWeight = 400)
    Local $s_VarBis, $i, $h_Print, $a, $w, $h
    $s_VarBis = StringReplace($s_Var, "&", "&&")
    Switch $s_FontName
        Case $cs_JpnFontName
            $w = $ci_JpnFontW
            $h = $ci_JpnFontH
    ;EndCase
    EndSwitch
        If $i_W = -1 Then $i_W = StringLen($s_VarBis) * $w
    If $i_H = -1 Then $i_H = $h
    Switch $i_Align
        Case 1
            $a = $SS_RIGHT
        Case 2
            $a = $SS_CENTER
        Case Else
            $a = $SS_LEFT
    ;EndCase
    EndSwitch
    $h_Print = GUICtrlCreateLabel($s_VarBis, $i_X, $i_Y, $i_W, $i_H, $a)
    GUICtrlSetFont(-1, $n_FontSize, $i_FontWeight, $i_FontAttr, $s_FontName)
    If $i_BkColor = -1 Then
        GUICtrlSetBkColor(-1, $GUI_BKCOLOR_DEFAULT); use default background color, defined by GUISetBkColor()
    ElseIf $i_BkColor = -2 Then
        GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT); use transparent background
    Else        
        GUICtrlSetBkColor(-1, $i_BkColor)
    EndIf
    If $i_Color = -1 Then
        GUICtrlSetColor(-1, 0x000000)
    Else
        GUICtrlSetColor(-1, $i_Color)
    EndIf
    Return $h_Print
EndFunc

Charvi

Link to comment
Share on other sites

Okay, I made the shortest test script, and it does NOT work.

Save this as JpConst.au3

Global $s = "日本の会社の名前"

and this as JpMain.au3

#include "JpConst.au3"
msgbox(0, "", $s)

and execute JpMain.au3 and you will get garbage.

Now try this:

Global $s = "日本の会社の名前"
msgbox(0, "", $s)

and it WILL work!

Conclusion: Unicode is not yet compatible with #include :)

Cheers, Charvi

Link to comment
Share on other sites

Okay, I made the shortest test script, and it does NOT work.

Save this as JpConst.au3

Global $s = "日本の会社の名前"

and this as JpMain.au3

#include "JpConst.au3"
msgbox(0, "", $s)

and execute JpMain.au3 and you will get garbage.

Now try this:

Global $s = "日本の会社の名前"
msgbox(0, "", $s)

and it WILL work!

Conclusion: Unicode is not yet compatible with #include :)

Cheers, Charvi

Would a developer be kind to confirm if it is a bug or my mistake?

Thanks and best regards

Link to comment
Share on other sites

  • Developers

could you attach the 2 script here for testing to ensure we test we the correct settings?

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...