Last active
December 19, 2015 15:19
-
-
Save rupertl/5975866 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use utf8; | |
use strict; | |
use warnings; | |
binmode(STDOUT, ":encoding(UTF-8)"); | |
use EBook::MOBI; | |
my $book = EBook::MOBI->new(); | |
$book->set_encoding(':encoding(UTF-8)'); | |
# These two lines work OK | |
$book->add_mhtml_content("<p>Here is some English text - Hello there!</p>\n"); | |
$book->add_mhtml_content("<p>Here is some German text - Viele Grüße!</p>\n"); | |
# These do not, showing garbled text when viewing in an eReader | |
$book->add_mhtml_content("<p>Here is some Chinese text - 你好!</p>\n"); | |
$book->add_mhtml_content("<p>Here is some Japanese text - お元気ですか!</p>\n"); | |
$book->add_mhtml_content("<p>End of text.</p>\n"); | |
$book->make(); | |
# Printing the raw mHTML shows the encoding is correct | |
$book->print_mhtml(); | |
$book->save(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment