Removed libiconv prefix (on OS X) to make encodings compile on OS X.
I am not sure since which version OS X does include the libiconv library without the `lib` prefix. But it seems this is the case for some years now. If there are ways to check for the OS X version at compile time this may be needed to support older OS X versions. But I guess thats not needed for most users working with Nim anyway.
This commit is contained in:
parent
8e4b5e10ba
commit
9b64a73bad
1 changed files with 4 additions and 10 deletions
|
|
@ -263,11 +263,6 @@ else:
|
||||||
else:
|
else:
|
||||||
const iconvDll = "(libc.so.6|libiconv.so)"
|
const iconvDll = "(libc.so.6|libiconv.so)"
|
||||||
|
|
||||||
when defined(macosx):
|
|
||||||
const prefix = "lib"
|
|
||||||
else:
|
|
||||||
const prefix = ""
|
|
||||||
|
|
||||||
const
|
const
|
||||||
E2BIG = 7.cint
|
E2BIG = 7.cint
|
||||||
EINVAL = 22.cint
|
EINVAL = 22.cint
|
||||||
|
|
@ -283,15 +278,15 @@ else:
|
||||||
var errno {.importc, header: "<errno.h>".}: cint
|
var errno {.importc, header: "<errno.h>".}: cint
|
||||||
|
|
||||||
proc iconvOpen(tocode, fromcode: cstring): EncodingConverter {.
|
proc iconvOpen(tocode, fromcode: cstring): EncodingConverter {.
|
||||||
importc: prefix & "iconv_open", cdecl, dynlib: iconvDll.}
|
importc: "iconv_open", cdecl, dynlib: iconvDll.}
|
||||||
proc iconvClose(c: EncodingConverter) {.
|
proc iconvClose(c: EncodingConverter) {.
|
||||||
importc: prefix & "iconv_close", cdecl, dynlib: iconvDll.}
|
importc: "iconv_close", cdecl, dynlib: iconvDll.}
|
||||||
proc iconv(c: EncodingConverter, inbuf: var cstring, inbytesLeft: var int,
|
proc iconv(c: EncodingConverter, inbuf: var cstring, inbytesLeft: var int,
|
||||||
outbuf: var cstring, outbytesLeft: var int): int {.
|
outbuf: var cstring, outbytesLeft: var int): int {.
|
||||||
importc: prefix & "iconv", cdecl, dynlib: iconvDll.}
|
importc: "iconv", cdecl, dynlib: iconvDll.}
|
||||||
proc iconv(c: EncodingConverter, inbuf: pointer, inbytesLeft: pointer,
|
proc iconv(c: EncodingConverter, inbuf: pointer, inbytesLeft: pointer,
|
||||||
outbuf: var cstring, outbytesLeft: var int): int {.
|
outbuf: var cstring, outbytesLeft: var int): int {.
|
||||||
importc: prefix & "iconv", cdecl, dynlib: iconvDll.}
|
importc: "iconv", cdecl, dynlib: iconvDll.}
|
||||||
|
|
||||||
proc getCurrentEncoding*(): string =
|
proc getCurrentEncoding*(): string =
|
||||||
## retrieves the current encoding. On Unix, always "UTF-8" is returned.
|
## retrieves the current encoding. On Unix, always "UTF-8" is returned.
|
||||||
|
|
@ -462,4 +457,3 @@ when not defined(testing) and isMainModule:
|
||||||
echo "Forced ibm850 encoding: ", ibm850
|
echo "Forced ibm850 encoding: ", ibm850
|
||||||
echo "Current encoding: ", current
|
echo "Current encoding: ", current
|
||||||
echo "From ibm850 to current: ", convert(ibm850, current, "ibm850")
|
echo "From ibm850 to current: ", convert(ibm850, current, "ibm850")
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue