raiju / phpMobi

An experimental Mobipocket file creator in PHP
Other
128 stars 32 forks source link

Fixing TOC links for UTF-8 text. #9

Closed grinvich11 closed 8 years ago

grinvich11 commented 8 years ago

More exact hit for text with multi-byte characters, but not completely

raiju commented 8 years ago

Sorry, didn't see the change until just now. Can you explain what you mean by "not completely"? Do you have an input example that breaks the TOC?

grinvich11 commented 8 years ago

For the English language does not changes. For the Russian language without mb_substr, when you click on chapter in the Table of Contents, jumping completely does not go where it is necessary. Using mb_substr gets closer to the desired chapter, but not to where it is necessary

raiju commented 8 years ago

Can you send me a text for which the alignment isn't right? I won't be able to take a good look at it this week, but I'll tackle it at the same time as #10. If you get me the bad file I should be able to get it fixed.

grinvich11 commented 8 years ago

Try this example and click on the links in the table of contents, and then try with my changes. sample.zip

raiju commented 8 years ago

Hmm, your code breaks the TOC even further, have you tested it? The file position in the TOC is a byte position, not dependent on the number of unicode chars, so mb_strlen seems inappropriate.

grinvich11 commented 8 years ago

With strlen transition is not next to the desired chapter, and using mb_strlen next to the desired chapter, but it does not matter now, because your changes fixed it