sonnykr
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2015
10:17 AM
Sanitize special characters
Hi All,
How can I santize special characters using brighscript? I tried something like
and it printed "0" instead of the actual ASCII value, which is "132"
The 2D api is skipping the special character, and leaving a space instead of rendering it. However, imagecanvas renders the special character just fine.
So 2 questions:
1. How to sanitize special character?
2. How to make 2D render special character?
Thanks!
How can I santize special characters using brighscript? I tried something like
print Asc("ä")
and it printed "0" instead of the actual ASCII value, which is "132"
The 2D api is skipping the special character, and leaving a space instead of rendering it. However, imagecanvas renders the special character just fine.
So 2 questions:
1. How to sanitize special character?
2. How to make 2D render special character?
Thanks!
12 REPLIES 12


Roku Employee
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2015
11:11 AM
Re: Sanitize special characters
Make sure your .brs source code file is UTF-8 encoded if you are embedding non-7-bit ASCII characters, e.g. in string constants.
Otherwise, characters should generally be specified as Unicode code points.
132 (&h84) does not appear to be a printable Unicode codepoint. If you want 'ä' that would be 228 (&hE4).
If you are getting different results depending on the drawing method it sounds like there are other issues.
Otherwise, characters should generally be specified as Unicode code points.
132 (&h84) does not appear to be a printable Unicode codepoint. If you want 'ä' that would be 228 (&hE4).
If you are getting different results depending on the drawing method it sounds like there are other issues.
sonnykr
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2015
11:57 AM
Re: Sanitize special characters
Make sure your .brs source code file is UTF-8 encoded if you are embedding non-7-bit ASCII characters, e.g. in string constants.
I tried Asc("ä") directly on Roku debugger console, and it returns 0 instead of the ASCII value.
renojim
Community Streaming Expert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2015
12:08 PM
Re: Sanitize special characters
I don't think you can do it from the debugger. If you put the statement in a UTF-8 encoded source file as KC suggested it will print "228".
-JT
-JT
Roku Community Streaming Expert
Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.
I am not a Roku employee.
Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.
I am not a Roku employee.


Roku Employee
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2015
12:10 PM
Re: Sanitize special characters
"sonnykr" wrote:Make sure your .brs source code file is UTF-8 encoded if you are embedding non-7-bit ASCII characters, e.g. in string constants.
I tried Asc("ä") directly on Roku debugger console, and it returns 0 instead of the ASCII value.
The console only supports 7-bit ASCII.
sonnykr
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2015
12:14 PM
Re: Sanitize special characters
oh! I see.. thank you RokuKc and renojim! That solves my first issue.
Still unsure why roScreen does not render special chars
Still unsure why roScreen does not render special chars
EnTerr
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2015
12:30 PM
Re: Sanitize special characters
Telnet console is a crank indeed, re i18n. worth(example) = lots * words, so:
BrightScript Debugger> s = chr(228): ? s, len(s), asc(s)
? 1 228


Roku Employee
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2015
01:56 PM
Re: Sanitize special characters
"sonnykr" wrote:
oh! I see.. thank you RokuKc and renojim! That solves my first issue.
Still unsure why roScreen does not render special chars
What font are you using?
sonnykr
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2015
06:08 PM
Re: Sanitize special characters
I am using a custom font from my client. Wondering whether its a font issue! but how come it works fine on imageCanvas? It render the special char very well on canvas. I'm kinda confused.
gabek
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2015
08:45 AM
Re: Sanitize special characters
If there are special tricks and or specific fonts to getting this working on an roScreen I'd love to learn more! I've tried many different fonts thinking that could be it, but have never been successful getting it to work. In my case I'm getting stuff out of ParseJSON. I've eventually just resorted to normalizing these characters on the backend as best as I can.
"RokuKC" wrote:"sonnykr" wrote:
oh! I see.. thank you RokuKc and renojim! That solves my first issue.
Still unsure why roScreen does not render special chars
What font are you using?