Re: Regex with ASCII and non-ASCII chars



TOXiC wrote:

Thx it work perfectly.
If I want to query a file stream?

file = open(fileName, "r")
text = file.read()
file.close()

Convert the bytes read from the file to unicode. For that you have to know
the encoding, e. g.

file_encoding = "utf-8" # replace with the actual encoding
text = text.decode(file_encoding)

regex = re.compile(u"(ÿÿ‹ð…öÂ)", re.IGNORECASE)
match = regex.search(text)
if (match):
result = match.group()
print result
WritePatch(fileName,text,result)
else:
result = "No match found"
print result

It return "no match found" (the file contain the string "ÿÿ‹ð…öÂ"
but...).
Thanks in advance for the help!

Peter
.



Relevant Pages

  • Re: Query output is always in UNICODE... need ANSI ... Help?
    ... > I'm using XP_Sendmail stored procedure to run a query and mail the ... > UNICODE and the application that subsequently consumes the attachment ... > unmodified attachment in ANSI format makes the application all happy ...
    (microsoft.public.sqlserver.programming)
  • Re: Query output is always in UNICODE... need ANSI ... Help?
    ... > I'm using XP_Sendmail stored procedure to run a query and mail the ... > UNICODE and the application that subsequently consumes the attachment ... > unmodified attachment in ANSI format makes the application all happy ...
    (microsoft.public.sqlserver)
  • Query output is always in UNICODE... need ANSI ... Help?
    ... I'm using XP_Sendmail stored procedure to run a query and mail the ... UNICODE and the application that subsequently consumes the attachment ... unmodified attachment in ANSI format makes the application all happy ...
    (microsoft.public.sqlserver.programming)
  • Query output is always in UNICODE... need ANSI ... Help?
    ... I'm using XP_Sendmail stored procedure to run a query and mail the ... UNICODE and the application that subsequently consumes the attachment ... unmodified attachment in ANSI format makes the application all happy ...
    (microsoft.public.sqlserver)
  • Re: convert unicode to ansi
    ... If I understand correctly you are having problem sending unicode query from ... You might try using NCHAR function to create queries which ... Research also the UNICODE function which is the reverse of NCHAR. ... > by using PHP queries: ...
    (microsoft.public.sqlserver.programming)