Skip to content
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

Adding a User with Persian Name in pyzk #190

Open
Haghghii opened this issue Jul 23, 2023 · 2 comments
Open

Adding a User with Persian Name in pyzk #190

Haghghii opened this issue Jul 23, 2023 · 2 comments
Labels
help wanted need more info More info is required to anaylize/fix the issue question

Comments

@Haghghii
Copy link

I am encountering difficulties when attempting to add a user with a Persian name in pyzk, a Python library for ZKTeco devices. Despite my efforts, the device does not accept Persian characters as valid input for user names. I have followed the provided documentation and attempted to use the set_user function with the Persian name as the name parameter, but it does not work as expected.

I would appreciate assistance in finding a solution or alternative approach that allows me to add a user with a Persian name successfully in pyzk.

@Haghghii Haghghii changed the title Adding a User with Persian Name in ZKTeco Py Adding a User with Persian Name in pyzk Jul 23, 2023
@kurenai-ryu
Copy link
Collaborator

Ok, you need to post some example code, with example data.
just to note that the zk constructor has a encoding parameter, that defaults to 'UTF-8'
Which is used inside some methods with this approach:

name_pad = name.encode(self.encoding, errors='ignore').ljust(24, b'\x00')[:24]

maybe the ignore errors makes the string empty or incomplete, in that case you need to provide a correct encoding.

@kurenai-ryu kurenai-ryu added help wanted question need more info More info is required to anaylize/fix the issue labels Jul 24, 2023
@core-burner
Copy link

core-burner commented Aug 18, 2024

Encoding is indeed UTF-8 but according to

name_pad = name.encode(self.encoding, errors='ignore').ljust(24, b'\x00')[:24]

with persian characters(2-3 bytes in UTF-8) the name length is limited 8 to 12 letters. It's not a good place to store names. This should depend on device. If there is an error, res needs to be provided.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted need more info More info is required to anaylize/fix the issue question
Projects
None yet
Development

No branches or pull requests

3 participants