Support custom encodings on Windows through GNU libiconv#11480
Merged
straight-shoota merged 4 commits intoNov 26, 2021
Conversation
oprypin
reviewed
Nov 20, 2021
straight-shoota
approved these changes
Nov 20, 2021
oprypin
reviewed
Nov 20, 2021
Co-authored-by: Oleh Prypin <[email protected]>
oprypin
approved these changes
Nov 20, 2021
Sija
reviewed
Nov 20, 2021
| require "c/stddef" | ||
|
|
||
| {% if flag?(:without_iconv) %} | ||
| {% raise "The `without_iconv` flag is preventing you to use the LibIconv module" %} |
Contributor
There was a problem hiding this comment.
Suggested change
| {% raise "The `without_iconv` flag is preventing you to use the LibIconv module" %} | |
| {% raise "The `without_iconv` flag is preventing you from using the LibIconv module" %} |
yxhuvud
reviewed
Nov 24, 2021
22 tasks
oprypin
approved these changes
Nov 24, 2021
Member
|
Every invocation of Crystal now gives a warning Currently that disrupts compilation of Shards |
This was referenced Nov 27, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds support for
IOs with custom encodings on Windows, using https://github.com/pffang/libiconv-for-Windows, which wraps GNU libiconv in an MSVC project.To make things work more generically across platforms, there is now a new flag
-Dwithout_iconvwhich disables both libiconv and the built-iniconv_*functions from the C library, plus all the associated tests; any attempt to use custom encodings will raise during runtime, similar to Windows before this PR. This is useful when the target platform has a poor iconv implementation (e.g. Android NDK) and libiconv is not yet available on that platform. The code below is all that is needed to select between libiconv and iconv at the moment:Thus Windows is hardcoded to use libiconv, and other platforms will continue to use iconv, but it is easy to change this in the future. If
-Dwithout_iconvis provided thensrc/crystal/iconv.critself would not be required.The decision to distinguish
LibIconvfromLibCis intentional, because they are not strictly API-compatible (e.g. FreeBSD has__iconv, GNU libiconv hasiconvctl).Related: #5430