Sign in to follow this  
Followers 0
jezzzzy

Strange symbol in string

8 posts in this topic

Characters like " - " (dash) and " ' " (apostrophe) are getting changed into strange looking characters (image attached). Here is some sample code:

;Write page to temp file
$webCode = _INetGetSource($wURL)
$file = FileOpen(@TempDir & "\temp.txt",2)
FileWrite($file,$webCode)
FileClose($file)

;Read contents of file into variables
$wTitle = _SRE_Between(StringStripWS(FileRead(@TempDir & "\temp.txt"), 4), '"Title"\>', '\<')

;Put the variables into GUI
GUICtrlSetData($lblTitle,($wTitle[0]))

If the contents of the HTML between the '"Title"\>' and the '\<' contains quotes, apostrophes, dashes, etc. they get displayed in my gui as strange characters as depicted in the attached .jpg. The .jpg sample character should be a regular dash. Can't figure this one out. If anyone needs me to post the functions, let me know. I'm pretty sure these are widely used and don't need to be included. Any help is appreciated.

Share this post


Link to post
Share on other sites



Instead of using _SRE_Between(), I re-wrote it, and it's in the standard UDFs in 3.2.2.0 now (Called _StringBetween()). Don't know if that will help you without you providing an actual example, but that's about all the advice I can give for now.

(P.S. you don't need to strip the Carriage Returns anymore).


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Thanks for the input smoke. I have upgraded to .2.2 and will test the new function. I hope it is the function, but I have a feeling that your function is not to blame. I'm working up some further tests to narrow down the cause. Also, you commented about needing an actual example: -- The code that I posted is the actual example. Let me know if you need more of it and I will post.

Share this post


Link to post
Share on other sites

Thanks for the input smoke. I have upgraded to .2.2 and will test the new function. I hope it is the function, but I have a feeling that your function is not to blame. I'm working up some further tests to narrow down the cause. Also, you commented about needing an actual example: -- The code that I posted is the actual example. Let me know if you need more of it and I will post.

The code "is" the example?

You mean this?

;Write page to temp file
$webCode = _INetGetSource($wURL)
$file = FileOpen(@TempDir & "\temp.txt",2)
FileWrite($file,$webCode)
FileClose($file)

;Read contents of file into variables
$wTitle = _SRE_Between(StringStripWS(FileRead(@TempDir & "\temp.txt"), 4), '"Title"\>', '\<')

;Put the variables into GUI
GUICtrlSetData($lblTitle,($wTitle[0]))
Um... :) ... What's $wURL? Just any URL? If that's the case, then I'll guarantee I'll not get the same results as you...

I would suggest either posting the URL that's giving you the issues if the new 3.2.2.0 doesn't work for you, or PM someone with it so they can maybe test what is going on if the URL is private.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Here is the complete code for a sample script to demonstrate the problem.

;Includes
#include <INet.au3>
#include <String.au3>

;Variables
$wURL = "http://dilbertblog.typepad.com/"

;Write page to temp file
$webCode = _INetGetSource($wURL)

;Read contents of file into variables
;$wTitle = _StringBetween(StringStripWS(FileRead(@TempDir & "\temp2.txt"),4), 'title>', '<') ;Non SRE Version
$wTitle = _StringBetween($webCode, 'furry', 'worth',-1,1) ;SRE Version

;Put the variables into GUI
If IsArray($wTitle) Then
    MsgBox(0,"$wTitle - $wTitleNonSRE",StringStripWS($wTitle[0],4))
Else
    MsgBox(0,"$wTitle - $wTitleNonSRE",$wTitle)
EndIf

Edit: Took out code that was writing to txt file. Irrelevant for this problem.

Edited by jezzzzy

Share this post


Link to post
Share on other sites

Solution:

Convert UTF-8 to ANSI. Thanks.

Share this post


Link to post
Share on other sites

Solution:

Convert UTF-8 to ANSI. Thanks.

Your welcome... I take it the revised script I sent you worked?

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
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
Sign in to follow this  
Followers 0