[Gambas-user] simple replace question

Benoît Minisini gambas at ...1...
Wed Mar 4 18:02:02 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.
>
> Sorry, I forgot this: you must replace 3/4 to something else before you
> can Conv to ASCII. Arrrgh - this will not run.
>
> Next idea: Look into the string and find out what Conv makes out of
> "3/4" in ASCII - maybe it just makes "3/4" out of it? This is what you
>
> will have to look for. Your thing would then read as follows:
>  >     TRY wx = Conv(lp1[5], "UTF-8", "ASCII")
>  >     TRY wx = Replace(wx, "½", ".5")
>  >     TRY wx = Replace(wx, "¼", ".25")
>  >     TRY wx = Replace(wx, "3/4", ".75")
>
> We would need a String.Replace() function here...
>
> Rolf
>

String.Replace() is not needed, because there is no difference between ASCII 
and UTF-8 when replacing strings.

There is no reason why Replace(st, "½", ".5") won't work, unless the st string 
is not UTF-8 of course.

Regards,

-- 
Benoît





More information about the User mailing list