View Single Post
Old 03-01-2015, 03:50 AM   #470
waterqds
Member
waterqds began at the beginning.
 
Posts: 11
Karma: 10
Join Date: Feb 2015
Device: Kindle Touch
I finally make it work.

1. Make Mobi2mobi GUI create its batch file in default system encoding, instead of UTF8.
In this way, the batch file can correct process local filenames, e.g. Chinese filename.

< Dim swBat As New StreamWriter(path, False, System.Text.Encoding.[Default])
---
> Dim swBat As StreamWriter = File.CreateText(path)

2. Adjust its GUI form to show the controls in my computer display better.

3. Now the hard part. Make mobiperl translate its command line parameters into UTF8 before update mobi file. You can not exec mobi2mobi.exe in command line or perl system() call to pass the UTF8 arguments. Program exec will go via local encoding.

I have changed the orginal mobiperl.pl into a Perl Module m2mrun.pm. The module has one interface m2mrun::m2mrun(...) which take the same arguments as the old command line. Of course, it has no issue with the UTF8 encoding now.

The only thing left is, write a new mobi2mobi.pl which translate its command line parameters from system encoding (GBK in my case) into UTF8 and call m2mrun(...).

Now all works fine. In order to work better, you can also change the Mobiperl::EXTH.pm, update all known EXTH names and binary EXTH tags.

Thanks for Jad, DiapDealer. Really appreciated it.
waterqds is offline   Reply With Quote