HTML characters convert {Resolved]

Just starting out? Need help? Post your questions and find answers here.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5502
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

HTML characters convert {Resolved]

Post 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
Last edited by Kwai chang caine on Fri Mar 01, 2024 3:36 pm, edited 1 time in total.
ImageThe happiness is a road...
Not a destination
SMaag
Enthusiast
Enthusiast
Posts: 327
Joined: Sat Jan 14, 2023 6:55 pm
Location: Bavaria/Germany

Re: HTML characters convert

Post 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$ 
User avatar
NicTheQuick
Addict
Addict
Posts: 1527
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: HTML characters convert

Post by NicTheQuick »

Just use the right character directly in your code:

Code: Select all

Text$ = ReplaceString(Text$, "%C5%93", "œ") ; oe
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
Little John
Addict
Addict
Posts: 4805
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: HTML characters convert

Post 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.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5502
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: HTML characters convert

Post 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
ImageThe happiness is a road...
Not a destination
User avatar
NicTheQuick
Addict
Addict
Posts: 1527
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: HTML characters convert

Post 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.
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5502
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: HTML characters convert {Resolved]

Post 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)
ImageThe happiness is a road...
Not a destination
Post Reply