Modify

Opened 4 years ago

Closed 4 years ago

#3821 closed Bug (Fixed)

_WinAPI_OemToChar should be forced to ASCII

Reported by: Nine Owned by: Jpm
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 Changed 4 years ago by Jpm

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 Changed 4 years ago by Jpm

  • Milestone set to 3.3.15.4
  • Owner set to Jpm
  • Resolution set to Fixed
  • Status changed from new to closed

Fixed by revision [12536] in version: 3.3.15.4

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as closed The owner will remain Jpm.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.