philotas
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2016
12:49 PM
Re: ifString.GetEntityDecode() ?
"EnTerr" wrote:
The strings already have getEntityEncode() method. The opposite is a one-liner:PRINT (myStringExpression).replace(""", """").replace("'", "'").replace("<", "<").replace(">", ">').replace("&", "&")
Correct. This is what I want to do, but without having to create this one-liner by hand for all entities out there, since there are more than the one in your example.
Update: I found that the above mentioned XmlDecode Function indeed work but it a quick test I did showed, that it does not work with entity names:
For example € works but € does not
EnTerr
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2016
01:51 PM
Re: ifString.GetEntityDecode() ?
"philotas" wrote:
Update: I found that the above mentioned XmlDecode Function indeed work but it a quick test I did showed, that it does not work with entity names: For example € works but € does not
That must be because XML has only 5 predefined char entites - where HTML has couple of hundreds of them.
Again - can you explain your use case?
How and why are you getting text encoded as HTML?
Why not receiving data in JSON or XML (or plain-old text in UTF8 for that matter).
I could sketch you a function to tackle that, were i persuaded it's necessary.
philotas
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2016
12:56 AM
Re: ifString.GetEntityDecode() ?
I receive (simple) HTML formatted text from a server via JSON and want to display it in Label.
I strip out some tags, but there could be some HTML Entities which I want to convert.
I strip out some tags, but there could be some HTML Entities which I want to convert.
EnTerr
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2016
09:26 AM
Re: ifString.GetEntityDecode() ?
"philotas" wrote:
I receive (simple) HTML formatted text from a server via JSON and want to display it in Label.
I strip out some tags, but there could be some HTML Entities which I want to convert.
Do you have the leeway to change that, as in simply not sending HTML?
That will make your life notably easier.
The reason being, you don't need HTML on Roku's side (not rendered) - nor do you need it for the transport, since JSON can transport all Unicode chars already, just make sure encoding for http is utf8 (should be the default already). The only concern remaining is that of having a font with the exotic glyphs, which has to be tackled either way.
philotas
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2016
03:30 PM
Re: ifString.GetEntityDecode() ?
"EnTerr" wrote:"philotas" wrote:
I receive (simple) HTML formatted text from a server via JSON and want to display it in Label.
I strip out some tags, but there could be some HTML Entities which I want to convert.
Do you have the leeway to change that, as in simply not sending HTML?
Unfortunately not for the time being.
EnTerr
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2016
07:15 PM
Re: ifString.GetEntityDecode() ?
I have to say, the part where parsing unknown character-entity-references fails miserably - i have no respect for that. Even if that's mandated by a spec, the pragmatic thing would have been to leave unrecognized items alone:
Here is a $64k question: does roXmlElement.parse() support DTDs? Because if it does... piece of cake, we can just do something like this and the entities will get defined and handled:
Brightscript Debugger> xml = CreateObject("roXmlElement")
Brightscript Debugger> ? xml.parse("<x>€ and €</x>"), xml.getText()
false
Brightscript Debugger> ? xml.parse("<x>just €</x>"), xml.getText()
true just €
Here is a $64k question: does roXmlElement.parse() support DTDs? Because if it does... piece of cake, we can just do something like this and the entities will get defined and handled:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE x PUBLIC "-//W3C//ENTITIES Special for XHTML//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml-special.ent">
<x> ...
EnTerr
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2016
08:45 PM
Re: ifString.GetEntityDecode() ?
Affirmative on DTD support!
[spoiler=victory is mine:sibykd31][youtube:sibykd31]x3rWRLOZX6U[/youtube:sibykd31][/spoiler:sibykd31]
Brightscript Debugger> dtd2 = "<!DOCTYPE x [ <!ENTITY euro ""€""> ]>"
Brightscript Debugger> ? xml.parse(dtd2 + "<x>mwa€hahaha</x>"), xml.getText()
true mwa€hahaha
[spoiler=victory is mine:sibykd31][youtube:sibykd31]x3rWRLOZX6U[/youtube:sibykd31][/spoiler:sibykd31]
belltown
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2016
12:16 AM
Re: ifString.GetEntityDecode() ?
"philotas" wrote:
I receive (simple) HTML formatted text from a server via JSON and want to display it in Label.
I strip out some tags, but there could be some HTML Entities which I want to convert.
Even if you are able to convert html-formatted JSON text to display in a Label, bear in mind that you may still need to convert some characters to characters that your Roku font can handle. This applies regardless of whether the character is represented as an entity reference or even as a raw Unicode codepoint.
For instance, while the Euro character (8364) may render correctly, a character such as a hyphen (8208) will not, so you'd have to do something like:
text = text.Replace(Chr(8208), "-")
- « Previous
-
- 1
- 2
- Next »