La Vita è Bella

Saturday, January 22, 2011

Fix epubs

The wonderful epub reader for Android, Aldiko, released a major update recently. Besides some great new features/improvements, it also broke something: all Chinese characters in Pro Git Chinese version can't be displayed. But it didn't simply broke Chinese epubs at all. My other Chinese epubs are just fine.

I contacted Aldiko for help, they just replied claiming that I need to embed Chinese font into epub for them to display, and Adobe Digital Edition have the same problem. I tried my epubs with Adobe Digital Edition and it's really the same. But after I looked into my good and broken epubs (they are simply zip archives with metadata, html, css and pictures inside), I can't find embedded Chinese font (in the good ones, of course) at all.

Instead, I found something else interesting: all my good epubs have an "xml:lang" parameter set to "zh-CN" in every html tag, and the broken one didn't.

So I add that parameter to every html file in progit-zh.epub, and repack the file, now it works (in both Aldiko and Adobe Digital Edition)!

To simplify this work, I wrote a python script to do that automatically. It will unpack the epub file into a temp directory, add "xml:lang" parameter to every html file if didn't present, and then pack the epub back again. It will also output the replaced lines into stderr, like:

<html xmlns="">
<html xmlns="" xml:lang="zh-CN">

Get it from my script repo on GitHub, and change the LANG constant if needed.

If you have other ideas about it, please let me know.

tags: , , ,

21:28:08 by fishy - i18n.zh - Permanent Link

no comments yet - no trackbacks yet - karma: 25 [+/-]

Tuesday, March 15, 2005

Perfect latex-beamer Chinese support

Just resolved the last problem in latex-beamer's Chinese support: Chinese PDF bookmark.

Howto? Just use the following command to compile it:

pdflatex beamer_slide.tex
pdflatex beamer_slide.tex
gbk2uni beamer_slide.out
pdflatex beamer_slide.tex

tags: , , ,

18:33:00 by fishy - i18n.zh - Permanent Link

no comments yet - no trackbacks yet - karma: 35 [+/-]

Tuesday, January 25, 2005

Resolved encoding problem in Vim

I've resolved the annoying encoding problem in vim today, and my Vim can handle UTF-8 encoded Chinese files correctly now :)

Just insert the following script into the vimrc file:

set fencs=gb18030,utf-8

In which "fencs" stands for "fileencodings".

The first one (gb18030) will be used for new files. While opening a file, vim will try to convert it use the first one, and the second one if failed, and third...

And I can convert a file between GB18030 and UTF-8 easily with vim now. Just open it, and then set fenc to the desired encoding, then write it, that's all

Vim is pretty good :)

tags: , , ,

00:19:00 by fishy - i18n.zh - Permanent Link

no comments yet - no trackbacks yet - karma: 34 [+/-]

May the Force be with you. RAmen