Skip to content

Use iconv() in utf8.cpp module on non-Windows platforms. - #174

Open
daliborfox wants to merge 1 commit into
OpenTS-Developers:mainfrom
daliborfox:utf8-use-iconv-non-windows
Open

daliborfox wants to merge 1 commit into
OpenTS-Developers:mainfrom
daliborfox:utf8-use-iconv-non-windows

Conversation

@daliborfox

@daliborfox daliborfox commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

The UTF-8 module contains a Best_Fit_Index() function which maps Unicode values to Windows-1252 or OEM 437 values, and uses WideCharToMultiByte() for this purpose, combined with a caching mechanism.

This commit adds support for this function on non-Windows platforms by using iconv() to perform the character conversion.

I've prepared the following test program to check that it works: utf8-test.cpp

Comparing the differences between Linux and Windows, the only one I see is that Linux / glibc's iconv() converts u2022, which corresponds to the 0x07 bullet in OEM 437, to a lower-case 'o'. I'd imagine this is benign, since the values below 0x20 are discarded anyways (is this intentional for OEM 437? It does contain graphical symbols there):
image

The one somewhat not-nice thing is that since the UTF8 module doesn't seem to contain a shutdown routine / destructor, the conversion state variables never get freed.

@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown

Development builds of d8915fb:

The links work without a GitHub account. Artifacts expire after 90 days, and this comment follows the latest successful build.

This branch has not been deployed

No deployments
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.

1 participant