Page 1 of 1

HTML characters convert {Resolved]

Posted: Fri Mar 01, 2024 12:32 pm
by Kwai chang caine
Hello at all :D

In French language there are a character "œ" made with 2 letters "o" and "e" glued together like for the word "cœur" => Heart in english :wink:
I try to convert an HTML sentence with this word inside, for example :
I love PureBasic and all the members of his forum, of all my ''cœur'' 8)

and when i run this code

Code: Select all

HtmlSentence$ = "I love PureBasic and all the members of his forum%2c of all my %27%27c%C5%93ur%27%27"

Text$ = ReplaceString(HtmlSentence$, "%27", "'")
Text$ = ReplaceString(Text$, "%2c", ",")
Text$ = ReplaceString(Text$, "%C5%93", Chr(156)) ; oe

Debug Text$
The answer is :|
Debugger wrote:I love PureBasic and all the members of his forum, of all my ''cœur''
Like you see, the %C5%93 => "oe"=> chr(156) not appear,
U+0153 œ c5 93 LATIN SMALL LIGATURE OE
https://www.utf8-chartable.de/unicode-u ... ?start=256
but the quote ' => chr(39) and the comma , => chr(44) yes :shock:

How can i force to write this character "%C5%93" => Chr(156) in my code ?

Have a good day

Re: HTML characters convert

Posted: Fri Mar 01, 2024 12:53 pm
by SMaag
if you look into Tools\Character Table, the 156 is empty.

I found with the Windows Tool CharacterTable the 'oe' as CHR(339)

Code: Select all

HtmlSentence$ = "I love PureBasic and all the members of his forum%2c of all my %27%27c%C5%93ur%27%27"

Text$ = ReplaceString(HtmlSentence$, "%27", "'")
Text$ = ReplaceString(Text$, "%2c", ",")
Text$ = ReplaceString(Text$, "%C5%93", Chr(339)) ; oe

Debug Text$ 

Re: HTML characters convert

Posted: Fri Mar 01, 2024 1:39 pm
by NicTheQuick
Just use the right character directly in your code:

Code: Select all

Text$ = ReplaceString(Text$, "%C5%93", "œ") ; oe

Re: HTML characters convert

Posted: Fri Mar 01, 2024 3:01 pm
by Little John
Kwai chang caine wrote: Fri Mar 01, 2024 12:32 pm
U+0153 œ c5 93 LATIN SMALL LIGATURE OE
U+153 is a hexadezimal value => Chr($153) in PureBasic.

Re: HTML characters convert

Posted: Fri Mar 01, 2024 3:35 pm
by Kwai chang caine
First hello at all, and thanks a lot for your quick answer 8)
@SMaag wrote:I found with the Windows Tool CharacterTable the 'oe' as CHR(339)
You have right :shock:
After reading the answer of Little John :wink: i understand why i confused with this value, it's the Hexa value not decimal :oops:
Thanks a lot for your code who perfectly works 8)
NicTheQuick wrote:Just use the right character directly in your code:
It's the first time i have try :wink:
But the problem, it's when i paste this character i don't know why the PB IDE (v5.73 and 6.0) show a little black square, not the "oe" :shock:
I have choose "UTF8" in the menu "File/File format" and it's the same thing :|
U+153 is a hexadezimal value => Chr($153) in PureBasic.
You have try the reason of my error 8)
Thanks to you, i understand now, even after numerous year in PB, i have always so much problem to manage UTF8 and HEXA :oops:

@All
Again thanks for your precious help and have a very good day

Re: HTML characters convert

Posted: Fri Mar 01, 2024 4:40 pm
by NicTheQuick
Kwai chang caine wrote: Fri Mar 01, 2024 3:35 pm
NicTheQuick wrote:Just use the right character directly in your code:
It's the first time i have try :wink:
But the problem, it's when i paste this character i don't know why the PB IDE (v5.73 and 6.0) show a little black square, not the "oe" :shock:
I have choose "UTF8" in the menu "File/File format" and it's the same thing :|
You may use a font in your IDE that does not come with that character. I use "Liberation Mono Regular" which works fine with a lot of special characters.

Re: HTML characters convert {Resolved]

Posted: Fri Mar 01, 2024 5:16 pm
by Kwai chang caine
You may use a font in your IDE.............
:shock:
I did not know, after several decade i use PB, it's possible to change the font :oops:

You know .... the numeric have his "UID" (Unique Identifier)
KCC have his "UIN" (Unique Intelligency Neuronal) and when you have like me this one, never you try to modify a default parameter :oops:
KCC is already so happy to see that run when he push the button START :lol:

So i have the default font "Courier Normal 10" :wink:
I have try your font and that works 8)

After....your font is when even different of courier and i'm feel a little bit lost, you also know..the olds not always like the change :lol:
I keep your font and see if i found a font more resembling to courier and able to write this damned "œ" or others damned characters :evil:
Thank you very much for your precious advise 8)