Giter Club home page Giter Club logo

Comments (6)

nwoods avatar nwoods commented on July 18, 2024 1

I submitted a pull request that seems to fix the issue, along with a few other problems I noticed while messing around with it. I think the main problem was that the indexing and retries didn't change when the encode() implementation was changed to use byte strings internally.

from python-iconv.

bodograumann avatar bodograumann commented on July 18, 2024

Thank you for reporting this issue.
I cannot fix this quickly though.

When running locally with python 3.9, I cannot even execute the existing unit tests successfully.
Loading the ASCII//TRANSLIT codec is not possible at all there. Though iconv on the command line works fine with it.
(So I’m not able to reproduce the problem right now ^^)
I’ll probably have to do some tests with pyenv / asdf and different python versions.
The version I originally used was probably 3.7.
Maybe there was some change in the c-api, but I can’t be sure.

If you could contribute something that would of course be highly appreciated.
Setting up a local dev environment is as simple as:

python -m venv env
source env/bin/activate
pip install -e .
python -m unittest

from python-iconv.

nwoods avatar nwoods commented on July 18, 2024

I'll see if I can find time to mess around with it in the next few days but no promises. I've never needed to use the buffer protocol before and after a quick glance at the documentation, I'm not overly optimistic that I'll be able to master it in a short timeframe. In particular, I didn't see an obvious way to translate the number of bytes converted into the number of characters converted. Maybe it's obvious to someone who has used that API before; I'll tinker a little more.

from python-iconv.

bodograumann avatar bodograumann commented on July 18, 2024

Haha, auto-closed on merge :-D
Thank you so much for your contribution.

Do you have other specific example strings that caused errors previously?
I would like to add some more unit tests.

from python-iconv.

bodograumann avatar bodograumann commented on July 18, 2024

I published v1.1.1 with the fix to pypi.

from python-iconv.

nwoods avatar nwoods commented on July 18, 2024

The original bug was in cases where the output string was longer than the input string. The easiest example is converting any string containing "™" (U+2122) from unicode (where it is 3 bytes) to ASCII//TRANSLIT, where it is rendered as "(TM)" (4 bytes). My other tinkering fixed bugs when errors was 'replace' or 'ignore'. I think any conversion that triggers those should do.

from python-iconv.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.