Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
RokuMarkn
Visitor

Re: Sanitize special characters

You may want to post your code and perhaps we can see the problem. This works for me and displays Unicode character U+E5 ("small a with ring above"). Of course the font you're using must contain the characters you're trying to print.


function main() as Void
reg = CreateObject("roFontRegistry")
reg.Register("pkg:/myfont.ttf")
font = reg.GetFont("myfont", 20, false, false)

screen = CreateObject("roScreen", true)
screen.SetMessagePort(CreateObject("roMessagePort"))
screen.Clear(&h800000FF)
s = "test:" + Chr(&hE5)
screen.DrawText(s, 100, 100, &h00FFFFFF, font)
screen.SwapBuffers()

while true
end while
end function


--Mark
0 Kudos
RokuKC
Roku Employee
Roku Employee

Re: Sanitize special characters

"gabek" wrote:
...
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.


Where are you getting the data string that you pass into ParseJSON from, and do you have an example you can share?

Assuming the data comes from a web service http response, is the content UTF-8 encoded and tagged?

I'm curious what "normalizing these characters on the backend" refers to...
does that refer to using \u escape sequences in the JSON for non-ASCII characters, or replacing them with 7-bit ASCII, or ?

I'm also curious if "tried many fonts" includes the default font, or if possibly there are some issues with specific custom fonts formats.

Thanks.
0 Kudos
sonnykr
Visitor

Re: Sanitize special characters

You may want to post your code and perhaps we can see the problem. This works for me and displays Unicode character U+E5 ("small a with ring above"). Of course the font you're using must contain the characters you're trying to print.


I tried ur sample snippet (actually, this is exactly how I draw my text too..) with 2 different fonts. One of them rendered the special character without any problem. However, the second one failed to render. Then I used a font editor and saw that there are no font equivalent to those special characters inside the font file itself. I strongly think that its the font issue.

Thanks guys!
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.