HtmlEncode with HTML entity name, is it possible?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I am using the following method to HtmlEncode
some text
that it's in Spanish
, like this:
string word = "configuración";
string encodedWord = System.Net.WebUtility.HtmlEncode(word);
The output is the expected:
configuración
But! the ó
text represents the HTML entity number for a latin small letter "o" with acute.
However, I want to know if there is a way - using a built-in function which I don't know, library, etc - to show the HTML entity name of the HTML entity number and also support other characters (like a generic solution).
What I've tried so far is to check for a HTML entities table (there were many when Googling but I used this one: http://www.ascii.cl/htmlcodes.htm) then created a custom method
for replacing the needed string
from the word by doing some mapping.
So, if the word contains ó
then the matching text will be replaced to it's HTML entity name which is oacute;
but it is really painful since there are plenty of cases/scenarios.
Finally, the desired output will be:
configuración
c# html-entities html-encode
add a comment |
I am using the following method to HtmlEncode
some text
that it's in Spanish
, like this:
string word = "configuración";
string encodedWord = System.Net.WebUtility.HtmlEncode(word);
The output is the expected:
configuración
But! the ó
text represents the HTML entity number for a latin small letter "o" with acute.
However, I want to know if there is a way - using a built-in function which I don't know, library, etc - to show the HTML entity name of the HTML entity number and also support other characters (like a generic solution).
What I've tried so far is to check for a HTML entities table (there were many when Googling but I used this one: http://www.ascii.cl/htmlcodes.htm) then created a custom method
for replacing the needed string
from the word by doing some mapping.
So, if the word contains ó
then the matching text will be replaced to it's HTML entity name which is oacute;
but it is really painful since there are plenty of cases/scenarios.
Finally, the desired output will be:
configuración
c# html-entities html-encode
add a comment |
I am using the following method to HtmlEncode
some text
that it's in Spanish
, like this:
string word = "configuración";
string encodedWord = System.Net.WebUtility.HtmlEncode(word);
The output is the expected:
configuración
But! the ó
text represents the HTML entity number for a latin small letter "o" with acute.
However, I want to know if there is a way - using a built-in function which I don't know, library, etc - to show the HTML entity name of the HTML entity number and also support other characters (like a generic solution).
What I've tried so far is to check for a HTML entities table (there were many when Googling but I used this one: http://www.ascii.cl/htmlcodes.htm) then created a custom method
for replacing the needed string
from the word by doing some mapping.
So, if the word contains ó
then the matching text will be replaced to it's HTML entity name which is oacute;
but it is really painful since there are plenty of cases/scenarios.
Finally, the desired output will be:
configuración
c# html-entities html-encode
I am using the following method to HtmlEncode
some text
that it's in Spanish
, like this:
string word = "configuración";
string encodedWord = System.Net.WebUtility.HtmlEncode(word);
The output is the expected:
configuración
But! the ó
text represents the HTML entity number for a latin small letter "o" with acute.
However, I want to know if there is a way - using a built-in function which I don't know, library, etc - to show the HTML entity name of the HTML entity number and also support other characters (like a generic solution).
What I've tried so far is to check for a HTML entities table (there were many when Googling but I used this one: http://www.ascii.cl/htmlcodes.htm) then created a custom method
for replacing the needed string
from the word by doing some mapping.
So, if the word contains ó
then the matching text will be replaced to it's HTML entity name which is oacute;
but it is really painful since there are plenty of cases/scenarios.
Finally, the desired output will be:
configuración
c# html-entities html-encode
c# html-entities html-encode
edited Nov 16 '18 at 13:30
Oscar Jara
asked Mar 17 '14 at 10:25
Oscar JaraOscar Jara
11.2k105088
11.2k105088
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
HtmlEncode(word); does only encode ISO 8859-1 (Latin-1). Which means your input needs to be encoded in ISO 8859-1. The ó is not in the iso standard, you can try to use the AntiXss encoder:
Microsoft.Security.Application.AntiXss.HtmlEncode("ó");
or Microsoft.Security.Application.Encoder.HtmlEncode("ó");
Sorry, I can't use this since I am under a console app and I think this is not related at all with encoding, really.
– Oscar Jara
Mar 17 '14 at 13:50
I've updated the answer, you can test if AntiXss HtmlEncode can handle the ó.
– Peter
Mar 17 '14 at 14:00
Hey, thanks for the hint! however usingMicrosoft.Security.Application.AntiXss.HtmlEncode
is deprecated. The right one to use is the following:Microsoft.Security.Application.Encoder.HtmlEncode
and setting totrue
the second argument of the constructor makes the html encode to show the named entities that I was looking for :-)
– Oscar Jara
Mar 18 '14 at 1:07
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f22451848%2fhtmlencode-with-html-entity-name-is-it-possible%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
HtmlEncode(word); does only encode ISO 8859-1 (Latin-1). Which means your input needs to be encoded in ISO 8859-1. The ó is not in the iso standard, you can try to use the AntiXss encoder:
Microsoft.Security.Application.AntiXss.HtmlEncode("ó");
or Microsoft.Security.Application.Encoder.HtmlEncode("ó");
Sorry, I can't use this since I am under a console app and I think this is not related at all with encoding, really.
– Oscar Jara
Mar 17 '14 at 13:50
I've updated the answer, you can test if AntiXss HtmlEncode can handle the ó.
– Peter
Mar 17 '14 at 14:00
Hey, thanks for the hint! however usingMicrosoft.Security.Application.AntiXss.HtmlEncode
is deprecated. The right one to use is the following:Microsoft.Security.Application.Encoder.HtmlEncode
and setting totrue
the second argument of the constructor makes the html encode to show the named entities that I was looking for :-)
– Oscar Jara
Mar 18 '14 at 1:07
add a comment |
HtmlEncode(word); does only encode ISO 8859-1 (Latin-1). Which means your input needs to be encoded in ISO 8859-1. The ó is not in the iso standard, you can try to use the AntiXss encoder:
Microsoft.Security.Application.AntiXss.HtmlEncode("ó");
or Microsoft.Security.Application.Encoder.HtmlEncode("ó");
Sorry, I can't use this since I am under a console app and I think this is not related at all with encoding, really.
– Oscar Jara
Mar 17 '14 at 13:50
I've updated the answer, you can test if AntiXss HtmlEncode can handle the ó.
– Peter
Mar 17 '14 at 14:00
Hey, thanks for the hint! however usingMicrosoft.Security.Application.AntiXss.HtmlEncode
is deprecated. The right one to use is the following:Microsoft.Security.Application.Encoder.HtmlEncode
and setting totrue
the second argument of the constructor makes the html encode to show the named entities that I was looking for :-)
– Oscar Jara
Mar 18 '14 at 1:07
add a comment |
HtmlEncode(word); does only encode ISO 8859-1 (Latin-1). Which means your input needs to be encoded in ISO 8859-1. The ó is not in the iso standard, you can try to use the AntiXss encoder:
Microsoft.Security.Application.AntiXss.HtmlEncode("ó");
or Microsoft.Security.Application.Encoder.HtmlEncode("ó");
HtmlEncode(word); does only encode ISO 8859-1 (Latin-1). Which means your input needs to be encoded in ISO 8859-1. The ó is not in the iso standard, you can try to use the AntiXss encoder:
Microsoft.Security.Application.AntiXss.HtmlEncode("ó");
or Microsoft.Security.Application.Encoder.HtmlEncode("ó");
edited Mar 18 '14 at 8:58
answered Mar 17 '14 at 13:49
PeterPeter
24.1k74674
24.1k74674
Sorry, I can't use this since I am under a console app and I think this is not related at all with encoding, really.
– Oscar Jara
Mar 17 '14 at 13:50
I've updated the answer, you can test if AntiXss HtmlEncode can handle the ó.
– Peter
Mar 17 '14 at 14:00
Hey, thanks for the hint! however usingMicrosoft.Security.Application.AntiXss.HtmlEncode
is deprecated. The right one to use is the following:Microsoft.Security.Application.Encoder.HtmlEncode
and setting totrue
the second argument of the constructor makes the html encode to show the named entities that I was looking for :-)
– Oscar Jara
Mar 18 '14 at 1:07
add a comment |
Sorry, I can't use this since I am under a console app and I think this is not related at all with encoding, really.
– Oscar Jara
Mar 17 '14 at 13:50
I've updated the answer, you can test if AntiXss HtmlEncode can handle the ó.
– Peter
Mar 17 '14 at 14:00
Hey, thanks for the hint! however usingMicrosoft.Security.Application.AntiXss.HtmlEncode
is deprecated. The right one to use is the following:Microsoft.Security.Application.Encoder.HtmlEncode
and setting totrue
the second argument of the constructor makes the html encode to show the named entities that I was looking for :-)
– Oscar Jara
Mar 18 '14 at 1:07
Sorry, I can't use this since I am under a console app and I think this is not related at all with encoding, really.
– Oscar Jara
Mar 17 '14 at 13:50
Sorry, I can't use this since I am under a console app and I think this is not related at all with encoding, really.
– Oscar Jara
Mar 17 '14 at 13:50
I've updated the answer, you can test if AntiXss HtmlEncode can handle the ó.
– Peter
Mar 17 '14 at 14:00
I've updated the answer, you can test if AntiXss HtmlEncode can handle the ó.
– Peter
Mar 17 '14 at 14:00
Hey, thanks for the hint! however using
Microsoft.Security.Application.AntiXss.HtmlEncode
is deprecated. The right one to use is the following: Microsoft.Security.Application.Encoder.HtmlEncode
and setting to true
the second argument of the constructor makes the html encode to show the named entities that I was looking for :-)– Oscar Jara
Mar 18 '14 at 1:07
Hey, thanks for the hint! however using
Microsoft.Security.Application.AntiXss.HtmlEncode
is deprecated. The right one to use is the following: Microsoft.Security.Application.Encoder.HtmlEncode
and setting to true
the second argument of the constructor makes the html encode to show the named entities that I was looking for :-)– Oscar Jara
Mar 18 '14 at 1:07
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f22451848%2fhtmlencode-with-html-entity-name-is-it-possible%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown