Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
batch convert unicode characters to HTML entities
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
Schmoove
n00b
n00b


Joined: 17 Sep 2004
Posts: 8

PostPosted: Wed Mar 15, 2006 10:59 pm    Post subject: batch convert unicode characters to HTML entities Reply with quote

I just googled until my eyes got sore for help with my problem and now I hope to get help in this forum.

I am searching for a tool to batch convert unicode characters in an HTML document into HTML entities. I thought every HTML editor must come with such a function, but I wasn't even able to find any sort of tool to do such a task. I am using Quanta Plus. I must be braindead, becuase I can't imagine that I am the first person to want to do this and I can't find anything to help me out. PErhaps some nice person reading this can give me a hint where to look for such a tool.

Thanks,
Max
Back to top
View user's profile Send private message
ecatmur
Advocate
Advocate


Joined: 20 Oct 2003
Posts: 3595
Location: Edinburgh

PostPosted: Thu Mar 16, 2006 4:19 am    Post subject: Reply with quote

Surprisingly, this is actually a job for perl:
Code:
$ perl -CI -p -i -e 's/([^\x00-\x9F])/"\&#".ord($&).";"/eg'

This assumes UTF-8 input, and converts anything outside the (printable + control area) range to numeric references.

If you want something a little more robust, try uni2ascii, http://billposer.org/Software/uni2ascii.html
_________________
No more cruft
dep: Revdeps that work
Using command-line ACCEPT_KEYWORDS?
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum