Modify

#3821 closed Bug (Fixed)

_WinAPI_OemToChar should be forced to ASCII

Reported by: Nine Owned by: J-Paul Mesnage
Milestone: 3.3.15.4 Component: AutoIt
Version: 3.3.14.5 Severity: None
Keywords: Cc:

Description

As per this thread :
https://www.autoitscript.com/forum/topic/205736-solved-how-to-write-special-characters-to-scite-editor-moved/

Under certain conditions, the API switches to Unicode causing the script to crash. By forcing the function to use ASCII characters, the issue was solved. The revised function should look like this :

Func _WinAPI_OemToChar($sStr)
  Local $aRet = DllCall('user32.dll', 'bool', 'OemToCharA', 'str', $sStr, 'str', '')
  If @error Or Not $aRet[0] Then Return SetError(@error + 10, @extended, '')
  Return $aRet[2]
EndFunc   ;==>_WinAPI_OemToChar

Attachments (0)

Change History (3)

comment:2 by J-Paul Mesnage, on May 6, 2021 at 4:41:30 PM

Not sure the title is the right way to describe that when using _WinAPI_OemToChar() with string greater than 65536 a crash occurs
The pb is the same for _WinAPI_CharToOem()
the right solution is

Func _WinAPI_OemToChar($sStr)
	Local $aCall, $sRetStr = "", $nLen = StringLen($sStr) + 1, $iStart = 1

	While $iStart < $nLen
		$aCall = DllCall('user32.dll', 'bool', 'OemToCharA', 'str', StringMid($sStr, $iStart, 65536), 'str', '')
		If @error Or Not $aCall[0] Then Return SetError(@error + 10, @extended, '')
		$sRetStr &= $aCall[2]
		$iStart += 65536
	WEnd

	Return $sRetStr
EndFunc   ;==>_WinAPI_OemToChar

comment:3 by J-Paul Mesnage, on May 6, 2021 at 4:46:55 PM

Milestone: 3.3.15.4
Owner: set to J-Paul Mesnage
Resolution: Fixed
Status: newclosed

Fixed by revision [12536] in version: 3.3.15.4

Modify Ticket

Action
as closed The owner will remain J-Paul Mesnage.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.