Registry / serialization / iconv-corefoundation

iconv-corefoundation

JSON →
library1.1.7jsnpmunverified

Character set conversion library using macOS CoreFoundation API. Version 1.1.7. Pre-compiled native add-on using N-API 3. macOS-only (requires 10.10+). Supports all legacy Macintosh scripts including Mac OS Inuit and double-byte scripts. Not for general use; prefer iconv-lite for cross-platform needs. No streaming API. Built for Node.js 8.11.2+ and 10+. Ships TypeScript types. MIT license.

npm install iconv-corefoundation
INSTALL
IMPORT
SIG · ICONV-COREFOUNDATI
I
iconv-corefoundation
serializationjavascriptv1.1.7
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

StringEncoding
import { StringEncoding } from 'iconv-corefoundation'
import StringEncoding from 'iconv-corefoundation'
Named export, not default. Must be imported using named import syntax.
transcode
import { transcode } from 'iconv-corefoundation'
const transcode = require('iconv-corefoundation').transcode
ESM style works, but also available via CJS. TypeScript friendly with types.
encodeSmallest
import { encodeSmallest } from 'iconv-corefoundation'
const { encodeSmallest } = require('iconv-corefoundation')
Both ESM and CJS imports work. The named export is correct.

Demonstrates encoding/decoding and transcoding with StringEncoding and transcode function.

import { StringEncoding, transcode } from 'iconv-corefoundation'; // Get Mac OS Roman encoding const macRoman = StringEncoding.byIANACharSetName('macintosh'); // Encode a string const buf = macRoman.encode('Hello, world!'); console.log(buf); // <Buffer ...> // Decode back const str = macRoman.decode(buf); console.log(str); // 'Hello, world!' // Transcode directly between buffers (no JS string) const utf8Buf = Buffer.from('Hello, world!', 'utf8'); const latin1 = StringEncoding.byCFStringEncoding(0x0600); // kCFStringEncodingISOLatin1 const latin1Buf = transcode(utf8Buf, null, latin1); // null means UTF-8 console.log(latin1Buf);
Debug
Known issues
gotchaThis package only works on macOS. It will fail on Windows, Linux, or other platforms.
fix
Use a conditional import or alternative cross-platform library like iconv-lite.
affects: >=0.0.0
deprecatedNode.js versions 8 and 9 are unsupported outside of LTS. Pre-compiled binaries for old Node versions may be unavailable.
fix
Upgrade Node.js to 10.x or later.
affects: >=1.0.0 <1.2.0
gotchaStringEncoding cannot be constructed directly (new StringEncoding() fails). Use static methods like byCFStringEncoding, byIANACharSetName, etc.
fix
Call StringEncoding.by* methods to obtain an instance.
affects: >=0.0.0
breakingN-API version 3 is required. Older Node.js versions (below 8.11.2) are not supported.
fix
Use Node.js 8.11.2 or later, or 10+.
affects: >=1.0.0
gotchaNo streaming API. CoreFoundation does not support incremental conversion.
fix
Load entire string/buffer into memory before conversion.
affects: >=0.0.0
gotchaPerformance may be slow for large strings due to multiple copies.
fix
Benchmark with your data; consider alternatives for performance-sensitive tasks.
affects: >=0.0.0
gotchaBuilding from source requires Xcode command-line tools. GCC may not compile Core Foundation headers.
fix
Install Xcode CLI tools via xcode-select --install.
affects: >=0.0.0
Errors
Common errors & fixes
Error: The module 'iconv-corefoundation' was compiled against a different Node.js version using NODE_MODULE_VERSION 64. This version of Node.js requires NODE_MODULE_VERSION 72.
Pre-compiled binary incompatible with current Node.js version (e.g., Node 12 vs Node 14).
fix
Rebuild native addon: npm rebuild iconv-corefoundation
TypeError: Class constructor StringEncoding cannot be invoked without 'new'
Attempted to call StringEncoding() as a function instead of using static methods.
fix
Use StringEncoding.byCFStringEncoding(...) or similar static method.
Error: Dynamic loading not supported: this module works only on macOS
Tried to use the package on non-macOS system.
fix
Do not import on non-macOS platforms. Use conditional require: if (process.platform === 'darwin') { ... }
Error: Could not locate the bindings file. Tried: ...
Native addon .node file missing or not installed properly.
fix
Reinstall package: npm install iconv-corefoundation
Upgrade
Version history
1.1.7latest on npm
Audit
Dependencies
node-gypoptionalRequired for building native addon (pre-compiled binaries provided for macOS, but fallback build may need node-gyp)
Agent activity
10 hits · last 30 days
node
10
Resources