How convert a String to HTML Entity Codes?
Good morning everybody,
In Html sometimes we need to use entities code for don't have problems with browsers all over the world. Ex. 'á' is converted to code: 'á' / 'é' is converted to 'é'.
I have a question, how can i convert a string like my name to this type of code? Ex. "Flávio" will be "Flávio". I tried this way:
USER>write $zconvert("Flávio","I","HTML")
Flávio
but don't worked :(
Best Regards.
Product version: Caché 2018.1
A couple of things...
You'll want to use "O" (output) mode instead of "I" (input) mode:
write $zconvert("Flávio","O","HTML")
However, I see that this still doesn't replace the "á". But if I add an "&" it replaces it with "&" as expected:
write $zconvert("Flávio&","O","HTML")
The table at the bottom of this section in the documentation lists which characters are encoded into entities in HTML mode.
Interesting that it works in the opposite direction:
It's interesting.
I saw the table below, but don't have another function to do this convertion?
I think, the $zconvert() function will cover only the necessary entities. But you can use a simple method to convert characters to currently known(*) entities.
I have a table (the ^entityChars() global) which contains more the 1400 entities. You can download the above class, together with the table from my FTP server (File: DC.Entity.xml):
A sample output:
(*) Currently known, because (1) I do not have all the currently known entities in my table and (2) with each new day, the W3C and the Unicode consortium can extend the current entity list.
Thanks, I'm trying to access your ftp but i'm not getting. Can you import the file here in the answer?
@Flávio Lúcio Naves Júnior
usr= dcmember works. allow insecure port
You have to use the login data (as specified, this is not a anonymous FTP). On Windows: command line (cmd.exe), on Linux: terminal. Then (on both systems): ftp ftp.kavay.at, enter username and passwprd, then: get DC.Entity.xml.
Do you really want to see some 1470 lines of code here?
Why not to place it to some GitHub repo or at least gist?
Why not use numeric codes?
Social networks
InterSystems resources
Log in or sign up
Log in or create a new account to continue
Log in or sign up
Log in or create a new account to continue
Log in or sign up
Log in or create a new account to continue