
RokuMarkn
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2015
09:12 AM
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.
--Mark
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


Roku Employee
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2015
10:16 AM
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.
sonnykr
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2015
11:30 AM
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!
- « Previous
-
- 1
- 2
- Next »