replace and unicode?

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

replace and unicode?

Rick Harrison via use-livecode
Hi firends,

I am trying to replace "mm2" in a unicode text file with "mm(superscript2)"
but obviously "replace" does not do what I want or I am missing something!?

My effort so far:
...
## Read TXT file and make it LC compatible, this is doing fine:
put url ("binfile:" & tFile) into tData
put textdecode(tData,"UTF-8") into tDataComplete
replace CRLF with CR in tDataComplete

## Superscript 2 in Unicode
put numToCodepoint(0x00B2) into tSup

## But this line does nothing actually?
replace "mm2 " with ("mm" & tSup & " ") in tDataComplete
...

What am I missing or doing wrong?
Any hints appreciated, thank you!


Best

Klaus
--
Klaus Major
http://www.major-k.de
[hidden email]


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: replace and unicode?

Rick Harrison via use-livecode
On 2017-09-07 12:35, Klaus major-k via use-livecode wrote:

> Hi firends,
>
> I am trying to replace "mm2" in a unicode text file with
> "mm(superscript2)"
> but obviously "replace" does not do what I want or I am missing
> something!?
>
> My effort so far:
> ...
> ## Read TXT file and make it LC compatible, this is doing fine:
> put url ("binfile:" & tFile) into tData
> put textdecode(tData,"UTF-8") into tDataComplete
> replace CRLF with CR in tDataComplete
>
> ## Superscript 2 in Unicode
> put numToCodepoint(0x00B2) into tSup
>
> ## But this line does nothing actually?
> replace "mm2 " with ("mm" & tSup & " ") in tDataComplete

I tried:

put "mm2 foo Танюша mm2 bar" into tText
put numToCodepoint(0x00B2) into tSup
replace "mm2 " with ("mm" & tSup & " ") in tText
put tText

Here in a variety of versions and it seems to work...

What is the contents of tDataComplete in the case you can't get to work?

Warmest Regards,

Mark.

--
Mark Waddingham ~ [hidden email] ~ http://www.livecode.com/
LiveCode: Everyone can create apps

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: replace and unicode?

Rick Harrison via use-livecode
Hi Mark,

> Am 07.09.2017 um 12:47 schrieb Mark Waddingham via use-livecode <[hidden email]>:
>
> On 2017-09-07 12:35, Klaus major-k via use-livecode wrote:
>> Hi firends,
>> I am trying to replace "mm2" in a unicode text file with "mm(superscript2)"
>> but obviously "replace" does not do what I want or I am missing something!?
>> My effort so far:
>> ...
>> ## Read TXT file and make it LC compatible, this is doing fine:
>> put url ("binfile:" & tFile) into tData
>> put textdecode(tData,"UTF-8") into tDataComplete
>> replace CRLF with CR in tDataComplete
>> ## Superscript 2 in Unicode
>> put numToCodepoint(0x00B2) into tSup
>> ## But this line does nothing actually?
>> replace "mm2 " with ("mm" & tSup & " ") in tDataComplete
>
> I tried:
>
> put "mm2 foo Танюша mm2 bar" into tText
> put numToCodepoint(0x00B2) into tSup
> replace "mm2 " with ("mm" & tSup & " ") in tText
> put tText
>
> Here in a variety of versions and it seems to work...
>
> What is the contents of tDataComplete in the case you can't get to work?

The line in question before "replace":
40mm2 100mm2 200mm2

The line in question after "replace":
40mm2 100mm2 200mm2

???

Even this in a field with that line does not work?
...
put numToCodepoint(0x00B2) into tSup
replace "mm2 " with ("mm" & tSup & " ") in fld 1
...
?

Tried with LC 8.16 Stable on macOS 10.12.6.

> Warmest Regards,
>
> Mark.

Best

Klaus

--
Klaus Major
http://www.major-k.de
[hidden email]


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: replace and unicode?

Rick Harrison via use-livecode
Hi all,

so embarrassing, there was no SPACE after the mm2, but a TAB! :-/
So I got it working, thank you for your help.

> Am 07.09.2017 um 12:55 schrieb Klaus major-k via use-livecode <[hidden email]>:
> ...
>>> My effort so far:
>>> ...
>>> ## Read TXT file and make it LC compatible, this is doing fine:
>>> put url ("binfile:" & tFile) into tData
>>> put textdecode(tData,"UTF-8") into tDataComplete
>>> replace CRLF with CR in tDataComplete
>>> ## Superscript 2 in Unicode
>>> put numToCodepoint(0x00B2) into tSup
>>> ## But this line does nothing actually?
>>> replace "mm2 " with ("mm" & tSup & " ") in tDataComplete
>>
>> I tried:
>>
>> put "mm2 foo Танюша mm2 bar" into tText
>> put numToCodepoint(0x00B2) into tSup
>> replace "mm2 " with ("mm" & tSup & " ") in tText
>> put tText
>>
>> Here in a variety of versions and it seems to work...
>> What is the contents of tDataComplete in the case you can't get to work?
>
> The line in question before "replace":
> 40mm2 100mm2 200mm2
> The line in question after "replace":
> 40mm2 100mm2 200mm2
> ???
>
> Even this in a field with that line does not work?
> ...
> put numToCodepoint(0x00B2) into tSup
> replace "mm2 " with ("mm" & tSup & " ") in fld 1
> ...

Best

Klaus

--
Klaus Major
http://www.major-k.de
[hidden email]


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: replace and unicode?

Rick Harrison via use-livecode
On 2017-09-07 12:59, Klaus major-k via use-livecode wrote:
> Hi all,
>
> so embarrassing, there was no SPACE after the mm2, but a TAB! :-/
> So I got it working, thank you for your help.

That was going to be my next question - were the 'spaces' actually
spaces :)

Warmest Regards,

Mark.

--
Mark Waddingham ~ [hidden email] ~ http://www.livecode.com/
LiveCode: Everyone can create apps

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: replace and unicode?

Rick Harrison via use-livecode

> Am 07.09.2017 um 13:01 schrieb Mark Waddingham via use-livecode <[hidden email]>:
>
> On 2017-09-07 12:59, Klaus major-k via use-livecode wrote:
>> Hi all,
>> so embarrassing, there was no SPACE after the mm2, but a TAB! :-/
>> So I got it working, thank you for your help.
>
> That was going to be my next question - were the 'spaces' actually spaces :)

obviously they weren't! :-D
Thank you!

> Warmest Regards,
>
> Mark.
>
> --
> Mark Waddingham ~ [hidden email] ~ http://www.livecode.com/
> LiveCode: Everyone can create apps

Best

Klaus

--
Klaus Major
http://www.major-k.de
[hidden email]


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode