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

Fix convert #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Fix convert #3

wants to merge 2 commits into from

Conversation

nevar
Copy link

@nevar nevar commented Dec 17, 2012

If we convert from one byte to many byte, then may happen next.

Example of convert from windows-1251 to utf-8:

iconv ask to realloc buffer. We alloc odd byte. Next call to iconv failed to
write 2 byte utf symbol and return last result. Convert ended without fully
converted string.

Also add test.

iconv -f utf-8 -t windows-1251
Шашков Дени
Øàøêîâ Äåíè

New version:

4> iconv:start(), {ok, CD} = iconv:open("utf-8", "windows-1251"), V = <<"Øàøêîâ Äåíè">>, io:format("=~ts=~n", [element(2, iconv:conv(CD, V))]).
=Шашков Дени=

Old version:

1> iconv:start(), {ok, CD} = iconv:open("utf-8", "windows-1251"), V = <<"Øàøêîâ Äåíè">>, io:format("=~ts=~n", [element(2, iconv:conv(CD, V))]).
=Шашков Де=

Slava Yurin added 2 commits December 17, 2012 14:59
If we convert from one byte to many byte, then may happen next.

Example of convert from windows-1251 to utf-8:

iconv ask to realloc buffer. We alloc odd byte. Next call to iconv failed to
write 2 byte utf symbol and return last result. Convert ended without fully
converted string.
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.

None yet

1 participant