Genos Posted August 16, 2009 Share Posted August 16, 2009 I'm attempting to take user input and write that input into a file. The input includes japanese characters, but when I view the file the japanese text shows up only as ?s. Is there a way to store japanese characters? global $saveFilePath = FileSaveDialog("Save File", "", "Fcards deck (*.fcd)",2) & ".fcd" $saveFile = FileOpen ( $saveFilePath, 130 ) FileWriteLine($saveFile, "[Program Information]") FileWriteLine($saveFile, "Title = " & GUICtrlRead($txtTitle, 1)) FileWriteLine($saveFile, "Description = " & GUICtrlRead($txtDescription, 1)) FileWriteLine($saveFile, "Author = " & GUICtrlRead($txtAuthor, 1)) FileWriteLine($saveFile, "Version = " & GUICtrlRead($txtVersion, 1)) FileWriteLine($saveFile, "WebSite = " & GUICtrlRead($txtWebSite, 1)) FileWriteLine($saveFile, "") FileWriteLine($saveFile, "[Vocab]") $count = _GUICtrlListBox_GetCount($lstQuestion) $i = 0 while $i < $count FileWriteLine($saveFile, "que" & $i +1 & " = " & _GUICtrlListBox_GetText($lstQuestion,$i)) FileWriteLine($saveFile, "ans" & $i +1 & " = " & _GUICtrlListBox_GetText($lstAnswer,$i)) $i += 1 WEnd The Result is: [Program Information] Title = Japanese Numbers Description = Japanese Numbers, 1-100. Hiragana Author = Genos Version = 1.0 WebSite = http:// [Vocab] que1 = 1 ans1 = ?? que1 = 2 ans1 = ? que1 = 3 ans1 = ?? que1 = 4 ans1 = ?? que1 = 5 ans1 = ? que1 = 6 ans1 = ?? que1 = 7 ans1 = ?? que1 = 8 ans1 = ?? que1 = 9 ans1 = ??? que1 = 10 ans1 = ??? The ?? should be いち に さん etc.. I have tried opening the file in UTF8 and just regularly, but can't get it to show correctly in the file. Is there anyway for me to have AutoIt store japanese characters in a file using FileWriteLine()? Thanks in advance for your help. Link to comment Share on other sites More sharing options...
KaFu Posted August 16, 2009 Share Posted August 16, 2009 Switching SciTE to UCS-2 Little Endian and using fileopen with switch set to 34 works for me. OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Genos Posted August 16, 2009 Author Share Posted August 16, 2009 Switching SciTE to UCS-2 Little Endian and using fileopen with switch set to 34 works for me.Thanks for the response. I don't know what you mean by "Switching SciTE to UCS-2 Little Endian". How would I do this? Link to comment Share on other sites More sharing options...
Genos Posted August 16, 2009 Author Share Posted August 16, 2009 Ok, so in ScITE I did File -> Endoding -> UCS2-Little Endian, and used $saveFile = FileOpen ( $saveFilePath, 34 ) This did not work for me. Is this what you were recommending or did I do something else wrong? thanks again in advance. Link to comment Share on other sites More sharing options...
KaFu Posted August 17, 2009 Share Posted August 17, 2009 (edited) Yep, using UCS2-Little Endian in SciTE and fileopen with 34, this write the japanese chars to a text file correctly for me... though they are still not displayed correctly in the GUI! Maybe someone else can give input on this? #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Local $msg GUICreate("My GUI") ; will create a dialog box that when displayed is centered $input = GUICtrlCreateInput("いち", 10, 10, 100) $button = GUICtrlCreateButton("Write", 120, 10, 100) GUISetState(@SW_SHOW) ; will display an empty dialog box ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop If $msg = $button Then $saveFile = FileOpen("test.txt", 34) FileWriteLine($saveFile, GUICtrlRead($input)) FileClose($saveFile) EndIf WEnd GUIDelete() Edited August 17, 2009 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Genos Posted August 17, 2009 Author Share Posted August 17, 2009 Thanks, I appreciate the help. After running your code and seeing that it worked great (thanks!), I decided to check my method of obtaining the data from the listbox. Using _GUICtrlListBox_GetText($lstQuestion,$i) would result in reading ?? (verified by creating a popup with the data obtained from GetText). So I have found a workaround by using FileWriteLine($saveFile, "ans" & $i +1 & " = " & guictrlread($lstAnswer,1)) The only problem with this is that I have to set each item to selected using _guictrllistbox_setcursel($lstAnswer, $i) but it now reads, writes, and displays the japanese font. Thanks for your help >_< Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now