0
How to convert using Javascript:
The guy Java source string: \u900
for Unicode: ऀ
Today I have the following HTML element:
<i class="icon-zoom-out"></i>
And the CSS class:
@font-face {
font-family: 'iconcombo';
src:
url("#{$PATH_FONTS}iconcombo.ttf?g5kz9z") format("truetype");
font-weight: normal;
font-style: normal;
font-display: block;
}
[class^='icon-'],
[class*=' icon-'] {
/* use !important to prevent issues with browser extensions that change fonts */
font-family: 'iconcombo' !important;
speak: none;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
line-height: 1;
/* Better Font Rendering =========== */
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.icon-zoom-out:before {
content: '\e900';
}
The idea is that I don’t need to pass the class on the pseudo-element before, but incorporate directly:
<i>ऀ</i>
Suggestion:
function convertHexToUnicode(param) {
//aqui viria o método que faz a conversão
return resultConvertUnicode;
}
var icon = {
'zoom-out': '\ue900',
'zoom-in': '\ue901',
'zip-archive': '\ue902',
zip: '\ue903',
yen: '\ue904',
...
}
function getIcon(className, element) {
var resultUnicode = convertHexToUnicode(icon[className]);
element.innerHTML = '<i>'+resultUnicode+'</i>';
}
And how do you suggest this is done? You have an object that maps an icon name to your respective Unicode code point? I think it is worth [Edit] the question to add more details.
– Luiz Felipe
I can’t imagine how, if I had any idea, it wouldn’t be like a question. Mapping does not matter at this time, because a generic method could solve all the structures that will come, since it is the same type.
– Ivan Ferrer
See that it’s not a unusual doubt
– Ivan Ferrer
P.S. I edited, and added more details of the suggestion, as you suggested.
– Ivan Ferrer