[Gambas-user] simple replace question

Rolf-Werner Eilert eilert-sprachen at ...221...
Wed Mar 4 17:20:31 CET 2009


Bruce schrieb:
> On Thursday 05 March 2009 01:34:29 Rolf-Werner Eilert wrote:
>> newString = Conv(st, "UTF-8", "ASCII")
>>
>> Replace(st, "½", ".5")
> 
> Thanks RW,
> 
> That got me started at least.
> 
> So far:
>     TRY wx = Conv(lp1[5], "UTF-8", "ASCII")
>     TRY wx = Replace(wx, "½", ".5")
>     TRY wx = Replace(wx, "¼", ".25")
>     TRY wx = Replace(wx, "¾", ".75")
> seems to work.
> 
> I had to put the TRY's in because 3/4 doesn't seem to handle properly 
> otherwise.  
> 

No wonder, because 3/4 doesn't exist in ASCII. This is what my character 
table program says about this character:

UTF-8: 0xC2 0xBE
UTF-16: 0x00BE

C-Oktal terminiertes UTF-8: \302\276
Dezimale XML-Entität: ¾

So you should look for a string consisting of C2 and BE, that is 
chr$(194) and chr$(190) as we can presume this is UTF-8. Try this:

xStr = chr$(194) & chr$(190)
wx = Replace(wx, xStr, ".75")

Does this run? Or even

wx = Replace(wx, chr$(194) & chr$(190), ".75")

should work. At least if I'm right, but I never tried this.


Rolf




More information about the User mailing list