npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

iconv-corefoundation

v1.1.7

Published

Character set conversion using the macOS CoreFoundation API

Downloads

364,651

Readme

iconv-corefoundation

A Node.js library for character set conversion (like iconv-lite), using the macOS “Core Foundation” API.

This package contains a pre-compiled native add-on for Node.js, using N-API. See “System Requirements” below for details.

Why?

CoreFoundation.framework contains, to my knowledge, the only character set converter supporting all of the legacy Macintosh scripts, including non-Apple ones (such as Mac OS Inuit) and double-byte scripts (such as Mac OS Japanese). If your Node.js program needs to handle these, and runs only on macOS, this package may be your best bet.

This is not intended for general character set conversion needs. Use iconv-lite for that; it's not limited to a single platform, it doesn't have any native code, and it's probably faster. This package is for when you specifically need to use Core Foundation's character set conversion facilities.

License

iconv-corefoundation is provided under the terms of the MIT license. You can find the text of the MIT license in the LICENSE file.

System Requirements

Using

This package requires macOS, because it uses a macOS platform API (the Core Foundation framework) to do the actual work.

The native code portion of this package requires macOS 10.10 or newer.

This package requires N-API version 3, which is available in Node.js versions 8.11.2, 10, and newer (but not 9).

Building

Building this package isn't required to use it. Because this package only works on one platform, the native code is pre-compiled.

In addition to the system requirements for using this package, building it also requires the Xcode command-line tools to be installed. If they aren't, a window should appear offering to install them. If that doesn't work, run the command xcode-select --install to explicitly install them.

GCC does not seem to work; it fails to compile Core Foundation header files.

API

API documentation is in the docs folder.

The API for this package centers around the StringEncoding class. Each instance of this class represents a character encoding, such as ASCII or Mac OS Roman. To get a StringEncoding instance, call one of the static methods starting with by, such as byCFStringEncoding. (StringEncoding may not be constructed directly. It is instantiated only by native code.) Instances of StringEncoding have several informational properties (such as ianaCharSetName, the corresponding IANA character set name) and the methods encode and decode.

There are also several top-level functions exported by this package, like transcode (which converts one buffer to another, without creating a JavaScript string in between) and encodeSmallest (which encodes a string in the byte-wise smallest available encoding).

Caveats

I have not benchmarked this code. I do not expect it to be fast. Encoding and decoding strings involves copying the string at least once, which is a fairly expensive operation, especially with large strings.

There is no streaming API. Core Foundation does not seem to have any notion of streaming character set conversion, so neither does this package.