AutoHotkey Community

It is currently May 27th, 2012, 4:00 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 12 posts ] 
Author Message
PostPosted: May 19th, 2011, 1:19 pm 
This simple script:
Code:
msgbox ¿question?

Works well if the script is not compiled (the opening question mark "¿" appears fine).

But if I compile the script, that simbol is changed for "?" so what I see in the message box is "?question?" rather than "¿question?".

I'm using AHK_L (ansi) version 1.1 on Windows Vista.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 20th, 2011, 1:05 am 
Offline

Joined: May 3rd, 2009, 7:16 pm
Posts: 345
Location: OH, USA
Confirmed. However, this works:

Code:
MsgBox % Chr(191) . "question?"

Sounds like a bug in the compiler.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 20th, 2011, 2:10 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
Most likely not a bug. Read the Script File Codepage section:
http://www.autohotkey.net/~Lexikos/Auto ... pts.htm#cp


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 20th, 2011, 4:03 am 
Offline

Joined: May 3rd, 2009, 7:16 pm
Posts: 345
Location: OH, USA
@ Lexikos

I don't see anything there that explains why it would work uncompiled vs compiled. Also, works fine when compiled with AHK Basic. What am I missing?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 20th, 2011, 7:53 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
Quote:
Source files for compiled scripts must be encoded as UTF-8 or contain only ASCII characters.

I don't know how to make it more obvious than that.

If the script was encoded as UTF-8, it would not work on AutoHotkey Basic, which would misinterpret it as ANSI.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 20th, 2011, 6:00 pm 
But if I can't use extended ASCII characters with the ANSI installation, what is the use of it?

When you run the installation, it says the ANSI mode provides better compatibility for old scripts.
What kind of better compatibility could it provide if it's not the possibility of using extended ASCII chars ??


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 20th, 2011, 6:22 pm 
Offline

Joined: October 2nd, 2009, 12:43 pm
Posts: 283
Substitute AutoHotkeySC.bin from ANSI version.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 20th, 2011, 8:01 pm 
Offline

Joined: May 3rd, 2009, 7:16 pm
Posts: 345
Location: OH, USA
Lexikos wrote:
Quote:
Source files for compiled scripts must be encoded as UTF-8 or contain only ASCII characters.

I'm assuming that this doesn't include extended ASCII characters. It should probably be documented to prevent confusion.

I just find it odd that ANSI scripts can't be properly compiled with extended ASCII characters. For example, if this were written in Notepad, you wouldn't be able to compile without first getting a different text editor for UTF-8 encoding. :roll:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 20th, 2011, 9:50 pm 
Offline

Joined: October 2nd, 2009, 12:43 pm
Posts: 283
Quote:
For example, if this were written in Notepad, you wouldn't be able to compile without first getting a different text editor for UTF-8 encoding.

http://i.imgur.com/D97m0.png

Also, you are probably compiling with AutohotkeySC.bin from Unicode version.
Change it.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 20th, 2011, 10:54 pm 
Offline

Joined: May 3rd, 2009, 7:16 pm
Posts: 345
Location: OH, USA
flak wrote:

Nice. I never noticed this as I don't use Notepad much. However, my point still stands. IMO, it shouldn't be required to encode as UTF-8 for compiled ANSI scripts.

flak wrote:
Also, you are probably compiling with AutohotkeySC.bin from Unicode version.
Change it.

No. It seems UTF-8 encoding is required. Tested on 1.0.97.02 and 1.1.00.00 ANSI. Try it for yourself. Besides, if it were unicode, it wouldn't show a "?" as documented.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 22nd, 2011, 7:52 am 
Anonymous wrote:
But if I can't use extended ASCII characters with the ANSI installation, what is the use of it?

When you run the installation, it says the ANSI mode provides better compatibility for old scripts.
What kind of better compatibility could it provide if it's not the possibility of using extended ASCII chars ??

I'm quoting myself as I still dont understand why this is not a bug.
How could the ANSI build provide better compatibility if you cannot use extended ASCII characters??


What is the difference between ANSI and UTF-8 if you use only base ASCII characters (ASCII code less than 128) ??
I'll answer myself. There is no difference. It's exactly the same thing.

Quote:
Source files for compiled scripts must be encoded as UTF-8 or contain only ASCII characters.
This last statement is unnecessary because, as I said, UTF-8 and ASCII are compatible in the range 0-127.
Which finally means that ALL compiled scripts, no matter what, MUST be in UTF-8 only, and there is no ANSI support.

So there are two possibilities:
1. The documentation is wrong (or incomplete) as it doesn't clear the fact that there is no ANSI support for compiled scripts (only UTF-8)
2. The implementation is wrong (i.e. there is a bug)

Which one is wrong??


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 24th, 2011, 12:34 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
Anonymous wrote:
How could the ANSI build provide better compatibility if you cannot use extended ASCII characters??
See Script Compatibility.
Quote:
Quote:
Source files for compiled scripts must be encoded as UTF-8 or contain only ASCII characters.
This last statement is unnecessary
It isn't completely redundant. If a script has only ASCII characters, the author doesn't have to care about what encoding the editor thinks it's using. Not everyone knows what UTF-8 is.
Quote:
Which one is wrong??
Neither. See the link above. Strings in memory are in ANSI format. Even though the full range of Unicode characters can't be supported in the ANSI build, UTF-8 is more portable; i.e. it's not system-dependent. Ahk2Exe strips out the byte order mark if it is present, so jackieku (the original author of AutoHotkey's Unicode support) chose to make UTF-8 mandatory.

If you're compiling a script, it no longer needs to be able to run on any build other than the one you're compiling with. There's no point compiling with both AutoHotkey Basic and AutoHotkey_L. Changing a file's encoding to UTF-8 is much, much easier for most users than updating DllCall-heavy scripts to be Unicode-compatible.


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: Google Feedfetcher and 2 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