Android Question Replacing all occurrences of CHR(171) with Double Quotes, CHR(191) with CHR(172) and CHR(172) and with Single Quotes

beelze69

Active Member
Licensed User
Longtime User
Hi,

This is regarding character substitution in a string variable under b4A.


Doubt 1:

I want to perform the following steps on a string.

This String has, among other characters, many occurrences of CHR(171), CHR(191) and CHR(172)

1) Replace all occurrences of CHR(171) with "" i.e. Double QUotes

2) Replace all occurrences of CHR(191) [i.e. inverted Question mark symbol]
with CHR(172)

3) Replace all occurrences of CHR(172) with ' (i.e. single quote)


And the operations have to be performed in the above order.

Doubt 2:

How to assign the 'transformed string' as per above sequence to a label control in b4A ?


I mean, do I have to put any escape sequences for all the single quotes and the double quotes that will result from the above sequence of transformations ? Requesting for showing by an example.

Thanks..
 

edgar_ortiz

Active Member
Licensed User
Longtime User
You can try:

B4X:
StrInfo    = StrInfo.Replace(chr(171), chr(34))    ' Double Quotes
StrInfo    = StrInfo.Replace(chr(191), chr(172))
StrInfo    = StrInfo.Replace(chr(172), chr(39))    ' Single Quote
 
Upvote 0

beelze69

Active Member
Licensed User
Longtime User
Hi Edgar !! Thanks ! Will try this out... But when I am assigning the value of '
StrInfo' ' to a label control's Text property.. do I have to place any ESCAPE SEQUENCES ?
I mean can i say lblMyLabel.Text=StrInfo (where lblMyLabel is my Label control) ...
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
B4X:
    Dim StrInfo As String = $"${Chr(171)}${Chr(191)}${Chr(172)}"$
    Label1.Text = StrInfo.Replace(Chr(171),Chr(34)).Replace(Chr(191),Chr(172)).Replace(Chr(172),Chr(39))

 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…