AutoHotkey Community

It is currently May 27th, 2012, 11:22 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: July 5th, 2009, 7:17 pm 
Offline

Joined: April 28th, 2006, 12:12 pm
Posts: 55
I am using a very simple script that reads a random line from a text file and displays it in a message box when the hotkey is pressed.

The problem is that lines in the text file contain Greek and English words. When the message box appears, the Greek letters are not right:

άλογο - horse

instead of

άλογο - horse

How can I get the message box to display the Greek letters correctly? Please can somebody help me?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 5th, 2009, 8:06 pm 
Offline
User avatar

Joined: May 24th, 2009, 5:35 am
Posts: 2099
Location: Iowa, USA
I don't believe AHK currently supports Unicode characters - see here

For example, copy this: άλογο - horse
Code:
MsgBox % Clipboard ; displays ????? - horse


Edit - also see How to Unicode//Ascii in a MsgBox???


Last edited by jethrow on July 5th, 2009, 8:18 pm, edited 4 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 5th, 2009, 8:09 pm 
Offline

Joined: December 23rd, 2006, 6:02 pm
Posts: 424
Location: Russia
The file is apparently saved in UTF-8. Save it as ANSI, e.g. in Notepad.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 6th, 2009, 12:31 am 
Online
User avatar

Joined: October 7th, 2006, 8:45 am
Posts: 3330
Location: Simi Valley, CA
I hope you don't mind looking up the codes for unicode characters...

Code:
msgbox % MsgBoxW( 2, "{√Ⅹ∃}", "άλογο - horse" )

MsgBoxW( msg0, title="", text="" ) ; the "W" is for 'wide' chars
{ ; Function by [VxE]. A wrapper for the MessageBoxW function, which takes
; wide-char strings (unicode). Since AHK doesn't like unicode, the strings need
; to be converted (hence the A2W function).
; Before you ask... no, I don't know how to make it have a time limit
; function info @ http://msdn.microsoft.com/en-us/library/ms645511(VS.85).aspx
   static OwnerHWND, ResultList
   If !OwnerHWND
   {
      odhw = %A_DetectHiddenWindows%
      DetectHiddenWindows, on
      OwnerHWND := WinExist("Ahk_PID " . DllCall("GetCurrentProcessId"))
      DetectHiddenWindows, %odhw%
   }

   If !ResultList
      ResultList = OK,CANCEL,ABORT,RETRY,IGNORE,YES,NO,CLOSE,HELP,TRYAGAIN,CONTINUE,TIMEOUT

   If (title = "" && text = "" )
   { ; mode 1
      title := A_ScriptName
      text := msg0
      msg0 := 0
   }
   A2W( text )
   A2W( title )
   result := DllCall(   "MessageBoxW"
         , UInt, OwnerHWND
         , UInt, &text
         , UInt, &title
         , UInt, msg0   )
   Loop, Parse, ResultList, `,
      If (A_Index = result)
         return A_LoopField
   return result
}

A2W( byref str ) ; Ascii to Wide-char. Version 2.0
{ ; function by [VxE], returns a string in unicode format. Uses html-style
; codes for unicode characters (i.e. ሴ or 〹 ). Intended for
; external functions (via DllCall). Return value is the number of characters.
   text := str
   u := v := pos := 0
   Loop
      If (pos := InStr( text, "&#", 0, pos+1 ))
      && (pos2 := InStr( text, "`;", 0, pos ))
      {
         If (num := Abs("0" . SubStr( text, pos+2, pos2-pos-2 )))
         {
            u++
            u%u% := num
            StringReplace, text, text, % SubStr(text, pos, pos2-pos+1), % chr(4)
         }
      }
      Else   Break
   VarSetCapacity(str, 2+2*len:=StrLen(text), 0) ; make space and wipe bits
   Loop, Parse, text
      If (num := Asc(A_LoopField)) = 4
         v++, NumPut( u%v%, str, 2*A_Index-2, "UShort" )
      Else   NumPut( num, str, 2*A_Index-2, "UShort" )
   return len
}

_________________
Ternary (a ? b : c) guide     TSV Table Manipulation Library
Post code inside [code][/code] tags!


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 21 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group