String parsing to get non-unicode string

I’m reading in a text file, parsing it line by line, and then writing it back out in a while loop. If I do a “display dialog” on each line’s string (set x to paragraph i of y) I get ‘normal’ text. After I parse it (set szName to characters w thru z of x as string), I get unicode text.

Any help is much appreciated.

Here’s the relevant code snippet:


set filepath to "<path to file>"
set y to do shell script "cat " & filepath
...
...
set x to paragraph i of y
...
...
set z to offset of szIPStart in x
set w to offset of szIPEnd in x
set szIP to characters (z + 20) thru w of x as string

A “display dialog szIP” after the above applescript gives me “1 9 8 . 1 6 2 . 1 3 . 5” which is not desirable. Any help in resolving this will be much appreciated.

thanks,
Will

Solved it.

I changed

set szIP to characters (z + 20) thru w of x as string

to

set szIP to text (z + 20) thru w of x as string

Hi,

the first form works as well, but you must take care of the value of text item delimiters,
which is set to space for some reason.

set text item delimiters to {""}
set szIP to characters (z + 20) thru w of x as string

In the second form the string coercion is not needed

set szIP to text (z + 20) thru w of x