Skip to content

cmd/seriesmeta: Add Unicode normalization for book IDs #111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

arturdryomov
Copy link

The _seriesmeta trigger searches the content table for a book with the same ID as the inserted one.

SELECT COUNT() FROM content WHERE ImageId = new.ImageId

It works fine with ASCII IDs (which are kinda file paths BTW). However, when calling seriesmeta on macOS with Unicode file names being involved, it doesn’t work. This happens because IDs at content are NFC-normalized when macOS returns file paths as NFD-normalized strings. As an example (using Python):

>>> value_content = "file____mnt_onboard_Books_Сапковский__Час_презрения_kepub_epub"
>>> value_series = "file____mnt_onboard_Books_Сапковский__Час_презрения_kepub_epub"

>>> value_content == value_series
False
>>> unicodedata.is_normalized("NFC", value_content)
True
>>> unicodedata.is_normalized("NFC", value_series)
False
>>> unicodedata.is_normalized("NFD", value_content)
False
>>> unicodedata.is_normalized("NFD", value_series)
True

In other words, visually values might look the same but without the normalization the SQLite comparison will not work.

@arturdryomov
Copy link
Author

@pgaskin, PTAL.

@arturdryomov arturdryomov force-pushed the ad/series-unicode-norm branch from 53cf8e9 to 5a2ce9b Compare July 23, 2025 17:58
@pgaskin
Copy link
Owner

pgaskin commented Jul 25, 2025

Seems good. I'll merge it later.

Note that NickelSeries is currently the recommended solution for series metadata. I'm only keeping seriesmeta around for existing users and because I haven't got around to doing another release deprecating it yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants