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

fullwidth-quotes

v1.0.1

Published

Convert CJK quotation marks to fullwidth according to Unicode Standardized Variation Sequence (SVS)

Downloads

132

Readme

fullwidth-quotes

npm GitHub License: MIT

Convert CJK quotation marks to fullwidth according to Unicode Standardized Variation Sequence (SVS).

In Unicode 16.0, it supports fullwidth quotation marks with variation selectors.

Character | Unicode | Name --- | --- | --- “︀ | U+201C U+FE00 | Halfwidth Left Double Quotation Mark ”︀ | U+201D U+FE00 | Halfwidth Right Double Quotation Mark ‘︀ | U+2018 U+FE00 | Halfwidth Left Single Quotation Mark ’︀ | U+2019 U+FE00 | Halfwidth Right Single Quotation Mark “︁ | U+201C U+FE01 | Fullwidth Left Double Quotation Mark ”︁ | U+201D U+FE01 | Fullwidth Right Double Quotation Mark ‘︁ | U+2018 U+FE01 | Fullwidth Left Single Quotation Mark ’︁ | U+2019 U+FE01 | Fullwidth Right Single Quotation Mark

This library will help you to add variant selectors for quotation marks automatically.

It only effects on smart quotation marks (curly quotation marks) and will not have any effects on dumb quotation marks (straight quotation marks).

This requires font support, otherwise you won't be able to see the difference between the two.

Installation

# npm
npm install fullwidth-quotes

# yarn
yarn add fullwidth-quotes

# pnpm
pnpm add fullwidth-quotes

Usage

import { enableSvsQuotes } from "fullwidth-quotes";
enableSvsQuotes("“Hello world!”"); // Add U+FE00 after the `“` and `”` characters.
enableSvsQuotes("“Hello world!”", "zh-CN"); // Convert only Chinese and Japanese to fullwidth quotes.

import { LEFT_DOUBLE_QUOTE_FULLWIDTH, RIGHT_DOUBLE_QUOTE_FULLWIDTH } from "fullwidth-quotes/chars";
// You can also directly get the samples of these characters.

API

enableSvsQuotes

Convert CJK quotation marks to fullwidth according to Unicode Standardized Variation Sequence (SVS).

If quotation marks enclose the context of Chinese or Japanese (excluding Korean), then switch them to fullwidth.

If the second parameter locale is provided, the quotation marks will only be converted to fullwidth when the script of the locale is "Hani", "Hans", "Hant", or "Jpan".

disableSvsQuotes

Remove the variation selectors from all quotation marks to restore them to ambiguous pure characters.

alwaysToFullwidthQuotes (Not Recommended)

Always convert all quotation marks in the string to fullwidth, regardless of the context character.

In the parameters, you can decide whether to ignore and replace any variation selector if a quotation mark already contain it.

alwaysToHalfwidthQuotes (Not Recommended)

Always convert all quotation marks in the string to halfwidth, regardless of the context character.

In the parameters, you can decide whether to ignore and replace any variation selector if a quotation mark already contain it.

shouldFullwidth

Determine whether a string should be enclosed in fullwidth brackets or quotation marks.

Determine rules:

  1. Query whether the first or last characters of a string is full width characters, and return true if so.
  2. If there are ambiguous characters, query the second or penultimate characters, and so on.
  3. If the entire string contains ambiguous characters, return false.

isFullwidth

Check if a character is fullwidth. But treat hangul as halfwidth due to korean uses halfwidth punctuation marks, and treat empty string as ambiguous.

East Asian Width | Returns --- | --- fullwidth | true halfwidth | false wide | true narrow | false neutral | false ambiguous | null

Special | Returns --- | --- Quote + VS1 | false Quote + VS2 | true Hangul | false Empty String | null

toUnicodeStringSequence

Convert a string to Unicode sequence that won't divide the variation selectors or something else into single characters.

It will return an array where each element is a valid Unicode Variation Sequences.

License

fullwidth-quotes is available under the MIT License. See the LICENSE file for more info.