Jump to content

Special character handling unclear


Recommended Posts

I am busy with understanding AutoIt and to do that I make small programs to look of expections are in accordance with test result.

I have written a small piece, which I have used in the debugger to follow the results and pasted back the results as comment

#include <String.au3>

Global $test, $hex, $result1, $result2 
$hex="808182838485868788898A8B8C8D8F909192939495969798999A9B9C9D9E9FA0A1A2A3A4A5A6A7A8A9AAABACADAEAF"
$test=_HexToString($hex) & "Normal text"
; ¡¢£¤¥¦§¨©ª«¬­®¯Normal text
$result1 = StringRegExpReplace($test,"[\000-\377]","?")
;????????????????????????????????
$result2 = StringRegExpReplace($test,"[\200-\377]","?")
;?????????????????????Normal text
;
MsgBox(0,"",$test & @CRLF & $result1  & @CRLF & $result2)

The proggie creates some chars with codes of ox80 and higher.

I use the StringRegExpReplace with the patterns [\000-\377] and [\200-\377] to replace matches with ? (question marks).

I expected to see in $result1 only ???????????? and in

in result 2 all ????? followed by Normal text

Is my interpretation wrong?

Link to comment
Share on other sites

I am busy with understanding AutoIt and to do that I make small programs to look of expections are in accordance with test result.

I have written a small piece, which I have used in the debugger to follow the results and pasted back the results as comment

#include <String.au3>

Global $test, $hex, $result1, $result2 
$hex="808182838485868788898A8B8C8D8F909192939495969798999A9B9C9D9E9FA0A1A2A3A4A5A6A7A8A9AAABACADAEAF"
$test=_HexToString($hex) & "Normal text"
; ¡¢£¤¥¦§¨©ª«¬­®¯Normal text
$result1 = StringRegExpReplace($test,"[\000-\377]","?")
;????????????????????????????????
$result2 = StringRegExpReplace($test,"[\200-\377]","?")
;?????????????????????Normal text
;
MsgBox(0,"",$test & @CRLF & $result1  & @CRLF & $result2)

The proggie creates some chars with codes of ox80 and higher.

I use the StringRegExpReplace with the patterns [\000-\377] and [\200-\377] to replace matches with ? (question marks).

I expected to see in $result1 only ???????????? and in

in result 2 all ????? followed by Normal text

Is my interpretation wrong?

Run your script with AutoIt3A.exe (ANSI version) vice AutoIt3.exe. The PCRE is compiled with the Unicode option in the standard AutoIt. Your script works as you expect when run with the ANSI version of AutoIt, which has its PCRE compiled for ANSI mode.

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Run your script with AutoIt3A.exe (ANSI version) vice AutoIt3.exe. The PCRE is compiled with the Unicode option in the standard AutoIt. Your script works as you expect when run with the ANSI version of AutoIt, which has its PCRE compiled for ANSI mode.

:)

Many thanks,

This solves the problem for now.

I have to learn another environment at the moment that the need for Unicode support arises.

Bodo

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...