AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

UNICODE version of AutoHotkey
Goto page Previous  1, 2, 3 ... , 14, 15, 16  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
jackieku



Joined: 30 Nov 2008
Posts: 69

PostPosted: Sat Jan 16, 2010 3:01 am    Post subject: Reply with quote

@Lexikos
It seems those lines should be...
Code:
output_var.ByteLength() = is_binary_clipboard ? bytes_actually_read
         : (VarSizeType)_tcslen((LPCTSTR) output_buf) * sizeof(TCHAR);

The original code uses bytes_actually_read - 1, but after I read the current code I think it shouldn't be -1.

@fincs
Please read the codes in os_version.cpp, Win95orLater, Win98orLater, and WinMeorLater are set only when the system is Win9x.
Back to top
View user's profile Send private message
fincs



Joined: 05 May 2007
Posts: 474
Location: Seville, Spain

PostPosted: Sat Jan 16, 2010 10:33 am    Post subject: Reply with quote

Ah, I knew I was missing something :p
_________________
fincs
SciTE4AutoHotkey v2 script editor
[AutoHotkeyCE] [AutoHotkey_L]
Back to top
View user's profile Send private message
Lexikos



Joined: 17 Oct 2006
Posts: 4473
Location: Qld, Australia

PostPosted: Sat Jan 16, 2010 4:55 pm    Post subject: Reply with quote

jackieku wrote:
The original code uses bytes_actually_read - 1, but after I read the current code I think it shouldn't be -1.
I think that would make it inaccurate. See below:
Code:
-- script2.cpp/BIF_StrLen()
? aParam[0]->var->Length() + aParam[0]->var->IsBinaryClip() // i.e. Add 1 if it's binary-clipboard, as documented.

-- var.cpp/AssignClipboardAll()
mByteLength = actual_space_used - sizeof(TCHAR); // Omit the final zero-byte from the length in case any other routines assume that exactly one zero exists at the end of var's length.

I suppose it was originally intended to use the last byte of the binary clipboard data as the variable's null-terminator (while still including it in StrLen()), but since it isn't necessarily going to be zero (null) when read from an arbitrary file, it might not be safe.

Perhaps we should change mByteLength to match the actual size of the data, and also ensure the usual null-terminator is present (remove the - 1 from A below). Running the script below caused two assertion failures, leading me to lines A and B.
Code:
Clipboard := "TEST"
a := ClipboardAll
b := a
Code:
--A: var.cpp/AssignClipboardAll()
if (!Assign(NULL, space_needed - 1, true, false))

--B: var.cpp/AssignBinaryClip()
if (!Assign(NULL, source_var._CharLength()))
...
LPVOID binary_contents_max = (char *)binary_contents + source_var.mByteLength + sizeof(TCHAR);

--C: script.cpp/Perform()
? ARGVARRAW2->Length() + 1 // +1 to include the entire 4-byte terminator, which seems best in this case.

A should be SetCapacity() as space_needed is in bytes. It would make sense to add aExactSize=true, aObeyMaxMem=false to B, for consistency with A and because it is unlikely that the variable will need the extra space.

There's may be something else I've missed.


Edit - Hmm, the following shows "1,0" on AutoHotkeyU whereas it should show ",-2" Wink
Code:
MsgBox % DllCall("MulDiv", "int", 2, "interchangable", 4, "integer", 8, "intriguing") "," ErrorLevel
I'll take care of this one...
Back to top
View user's profile Send private message Visit poster's website
Lexikos



Joined: 17 Oct 2006
Posts: 4473
Location: Qld, Australia

PostPosted: Wed Jan 20, 2010 3:09 pm    Post subject: Reply with quote

In the current commit, Debugger::OutputDebug and Debugger::FileAppend allocate memory via tmalloc and never free it. I'll be replacing it with something like the following, which avoids any allocations if the response buffer is already large enough (i.e. from a previous packet):
Code:
int Debugger::WriteStreamPacket(LPCTSTR aText, LPCSTR aType)
{
   int err;
   size_t aTextLen = (_tcslen(aText)+1) * sizeof(TCHAR);
   mResponseBuf.WriteF("<stream type=\"%s\">", aType);

   // We could calculate the total required size in advance, but it would offer
   // minimal benefit to performance and significantly impact readability:

   DEBUGGER_EXPAND_RESPONSEBUF_IF_NECESSARY(DEBUGGER_BASE64_ENCODED_SIZE(aTextLen));
   mResponseBuf.mDataUsed += Base64Encode(mResponseBuf.mData + mResponseBuf.mDataUsed, (char*) aText, aTextLen);
   mResponseBuf.Write("</stream>");
   return SendResponse();
}

void Debugger::OutputDebug(LPCTSTR aText)
{
   if (!mHasStdErrHook)
      OutputDebugString(aText);
   else
      WriteStreamPacket(aText, "stderr");
}

bool Debugger::FileAppend(LPCTSTR aText)
{
   if (!mHasStdOutHook)
      return _fputts(aText, stdout) >= 0;
   else
      return WriteStreamPacket(aText, "stdout") == DEBUGGER_E_OK;
}
Back to top
View user's profile Send private message Visit poster's website
Convert .ahk to .exe
Guest





PostPosted: Wed Jan 27, 2010 1:27 pm    Post subject: Convert .ahk to .exe Reply with quote

Hi, is there any way how to transfer scripts created using your unicode AHK from .ahk to .exe file?
Back to top
rousni



Joined: 23 Mar 2006
Posts: 87

PostPosted: Mon Feb 01, 2010 10:30 am    Post subject: Reply with quote

Quote:
ahk --> exe?

Yes
AutohotkeySC.bin is in the zip
Back to top
View user's profile Send private message
scribbly



Joined: 24 Apr 2009
Posts: 9

PostPosted: Tue Feb 02, 2010 2:33 pm    Post subject: URLDownloadToFile Reply with quote

Am I right in thinking that URLDownloadToFile is not working in AHKU?
_________________
Scribbly
Back to top
View user's profile Send private message
jackieku



Joined: 30 Nov 2008
Posts: 69

PostPosted: Tue Feb 02, 2010 3:52 pm    Post subject: Re: URLDownloadToFile Reply with quote

scribbly wrote:
Am I right in thinking that URLDownloadToFile is not working in AHKU?

It works here.
Please try the Unicode build of AutoHotkey_L (see the first post) first. If it fails, please give us more details about your problem.
Back to top
View user's profile Send private message
scribbly



Joined: 24 Apr 2009
Posts: 9

PostPosted: Wed Feb 03, 2010 12:27 am    Post subject: Re: URLDownloadToFile Reply with quote

jackieku wrote:
scribbly wrote:
Am I right in thinking that URLDownloadToFile is not working in AHKU?

It works here.
Please try the Unicode build of AutoHotkey_L (see the first post) first. If it fails, please give us more details about your problem.


OK Thanks. I thought I saw a previous post that questioned if it was done, so I only tried once.

I'll investigate further, thanks
_________________
Scribbly
Back to top
View user's profile Send private message
Lexikos



Joined: 17 Oct 2006
Posts: 4473
Location: Qld, Australia

PostPosted: Wed Feb 03, 2010 6:48 am    Post subject: Reply with quote

I tested using the following:
Code:
UrlDownloadToFile, http://www.autohotkey.com/forum/viewtopic.php?p=328839#328839, %A_Desktop%\test.html
MsgBox % ErrorLevel

In L43 Unicode build there is a slight delay, then the command returns with ErrorLevel=1 and no file is created.
In L43 ANSI build, it completes successfully.

scribbly, please confirm how you were specifying the path for UrlDownloadToFile. I've identified an issue with A_Desktop and similar built-in variables (specifically, ones which use ReadRegString) which prevents the code above and below from working correctly:
Code:
MsgBox %A_Desktop%\test.html  ; omits \test.html

For the time being, the following appears to work:
Code:
MsgBox % A_Desktop "\test.html"
It should be fixed in the next revision.
Back to top
View user's profile Send private message Visit poster's website
majkinetor



Joined: 24 May 2006
Posts: 4116
Location: Belgrade

PostPosted: Wed Feb 03, 2010 2:59 pm    Post subject: Reply with quote

Hello.

I am trying to use Spell module with Unicode dictionaries. The module is very simple and it consist of several wrapped dll calls.

I used this code to tryout Serbian dictionary.

Code:
  word = абажуре

  hSpell := Spell_Init("dic\sр.aff", "dic\sr.dic")
  enc := SPell_GetEncoding(hSPell)
  MsgBox % enc  ; should be UTF-8

  msgbox % "Word: " word "`n" Spell_Spell(hSpell, word)   
return

#include Spell.ahk


Spell_Spell takes the word and checks if it exists in the dictionary. It works correctly with English example. but fails for Serbian dict. I also tried Latin dict with same effects.

I didn't try in to do the same in C but I thought its not needed because those are standard OpenOffice dictionaries.

Can you maybe help ?
TIA.
_________________


Last edited by majkinetor on Wed Feb 03, 2010 10:43 pm; edited 1 time in total
Back to top
View user's profile Send private message
scribbly



Joined: 24 Apr 2009
Posts: 9

PostPosted: Wed Feb 03, 2010 3:27 pm    Post subject: Reply with quote

Lexikos wrote:
I tested using the following:
scribbly, please confirm how you were specifying the path for UrlDownloadToFile. I've identified an issue with A_Desktop and similar built-in variables (specifically, ones which use ReadRegString) which prevents the code above and below from working correctly:
Code:
MsgBox %A_Desktop%\test.html  ; omits \test.html

For the time being, the following appears to work:
Code:
MsgBox % A_Desktop "\test.html"
It should be fixed in the next revision.


I think you've nailed it, my code:
Code:
   
sFile = %A_SCRIPTDIR%\full.html
...
URLDownloadToFile, %sURL%, %sFile%


I presume %A_SCRIPTDIR% is the culprit??
_________________
Scribbly
Back to top
View user's profile Send private message
fincs



Joined: 05 May 2007
Posts: 474
Location: Seville, Spain

PostPosted: Wed Feb 03, 2010 3:32 pm    Post subject: Reply with quote

@majkinetor:
Try the FileEncoding command, it may help...
_________________
fincs
SciTE4AutoHotkey v2 script editor
[AutoHotkeyCE] [AutoHotkey_L]
Back to top
View user's profile Send private message
majkinetor



Joined: 24 May 2006
Posts: 4116
Location: Belgrade

PostPosted: Wed Feb 03, 2010 6:29 pm    Post subject: Reply with quote

Nvm, i figured it out.
_________________
Back to top
View user's profile Send private message
Lexikos



Joined: 17 Oct 2006
Posts: 4473
Location: Qld, Australia

PostPosted: Thu Feb 04, 2010 11:24 am    Post subject: Reply with quote

scribbly wrote:
I presume %A_SCRIPTDIR% is the culprit??
No, A_ScriptDir is based on a static string calculated at startup, and does not use ReadRegString which is where the problem I encountered actually was/is. If it were the same problem, MsgBox %sFile% would show only the contents of A_SCRIPTDIR. From A_ProgramFiles to A_MyDesktop and a few others use ReadRegString.

The following completes successfully for me with the earlier L43 Unicode build:
Code:
sFile = %A_SCRIPTDIR%\full.html
sURL = http://www.autohotkey.com/forum/viewtopic.php?p=328643#328643
URLDownloadToFile, %sURL%, %sFile%
MsgBox % ErrorLevel
Did you check sURL and sFile immediately before URLDownloadToFile?
Code:
MsgBox %sURL%`n%sFile%
FileAppend, sURL=%sURL%, %sFile%  ; Confirm the script can write to sFile.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2, 3 ... , 14, 15, 16  Next
Page 15 of 16

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group