decancer
Advanced tools
Comparing version 2.0.2 to 3.0.0
{ | ||
"name": "decancer", | ||
"version": "2.0.2", | ||
"version": "3.0.0", | ||
"description": "A tiny package that removes common unicode confusables/homoglyphs from strings.", | ||
@@ -58,15 +58,15 @@ "author": "null8626", | ||
"optionalDependencies": { | ||
"@vierofernando/decancer-win32-x64-msvc": "2.0.2", | ||
"@vierofernando/decancer-darwin-x64": "2.0.2", | ||
"@vierofernando/decancer-linux-x64-gnu": "2.0.2", | ||
"@vierofernando/decancer-darwin-arm64": "2.0.2", | ||
"@vierofernando/decancer-android-arm64": "2.0.2", | ||
"@vierofernando/decancer-linux-arm64-gnu": "2.0.2", | ||
"@vierofernando/decancer-linux-arm64-musl": "2.0.2", | ||
"@vierofernando/decancer-win32-arm64-msvc": "2.0.2", | ||
"@vierofernando/decancer-linux-arm-gnueabihf": "2.0.2", | ||
"@vierofernando/decancer-linux-x64-musl": "2.0.2", | ||
"@vierofernando/decancer-win32-ia32-msvc": "2.0.2", | ||
"@vierofernando/decancer-android-arm-eabi": "2.0.2" | ||
"@vierofernando/decancer-win32-x64-msvc": "3.0.0", | ||
"@vierofernando/decancer-darwin-x64": "3.0.0", | ||
"@vierofernando/decancer-linux-x64-gnu": "3.0.0", | ||
"@vierofernando/decancer-darwin-arm64": "3.0.0", | ||
"@vierofernando/decancer-android-arm64": "3.0.0", | ||
"@vierofernando/decancer-linux-arm64-gnu": "3.0.0", | ||
"@vierofernando/decancer-linux-arm64-musl": "3.0.0", | ||
"@vierofernando/decancer-win32-arm64-msvc": "3.0.0", | ||
"@vierofernando/decancer-linux-arm-gnueabihf": "3.0.0", | ||
"@vierofernando/decancer-linux-x64-musl": "3.0.0", | ||
"@vierofernando/decancer-win32-ia32-msvc": "3.0.0", | ||
"@vierofernando/decancer-android-arm-eabi": "3.0.0" | ||
} | ||
} |
162
README.md
@@ -37,3 +37,3 @@ # decancer [![npm][npm-image]][npm-url] [![crates.io][crates-io-image]][crates-io-url] [![npm downloads][downloads-image]][downloads-url] [![crates.io downloads][crates-io-downloads-image]][crates-io-url] [![code style: prettier][prettier-image]][prettier-url] [![Build Status][ci-image]][ci-url] [![license][github-license-image]][github-license-url] [![BLAZINGLY FAST!!!][blazingly-fast-image]][blazingly-fast-url] | ||
- Its core is written in [Rust](https://www.rust-lang.org) and utilizes a form of **Binary Search** to ensure speed! | ||
- It's capable of filtering **215,361 (19.33%) different unicode codepoints** like: | ||
- By default, it's capable of filtering **215.356 (19.33%) different unicode codepoints** like: | ||
- All [whitespace characters](https://en.wikipedia.org/wiki/Whitespace_character) | ||
@@ -48,2 +48,3 @@ - All [diacritics](https://en.wikipedia.org/wiki/Diacritic), this also eliminates all forms of [Zalgo text](https://en.wikipedia.org/wiki/Zalgo_text) | ||
- C/C++ | ||
- Java | ||
- [Python](https://pypi.org/project/decancer-py) (unofficial) | ||
@@ -59,3 +60,3 @@ | ||
```toml | ||
decancer = "2.0.2" | ||
decancer = "3.0.0" | ||
``` | ||
@@ -93,3 +94,3 @@ | ||
<script type="module"> | ||
import init from 'https://cdn.jsdelivr.net/gh/null8626/decancer@v2.0.2/bindings/wasm/bin/decancer.min.js' | ||
import init from 'https://cdn.jsdelivr.net/gh/null8626/decancer@v3.0.0/bindings/wasm/bin/decancer.min.js' | ||
@@ -102,2 +103,48 @@ const decancer = await init() | ||
<details> | ||
<summary><b>Java</b></summary> | ||
### As a dependency | ||
In your `build.gradle`: | ||
```gradle | ||
repositories { | ||
maven { url 'https://jitpack.io' } | ||
} | ||
dependencies { | ||
implementation 'com.github.null8626:decancer:3.0.0' | ||
} | ||
``` | ||
In your `pom.xml`: | ||
```xml | ||
<repositories> | ||
<repository> | ||
<id>jitpack.io</id> | ||
<url>https://jitpack.io</url> | ||
</repository> | ||
</repositories> | ||
<dependencies> | ||
<dependency> | ||
<groupId>com.github.null8626</groupId> | ||
<artifactId>decancer</artifactId> | ||
<version>3.0.0</version> | ||
</dependency> | ||
</dependencies> | ||
``` | ||
### Building from source | ||
```console | ||
$ git clone https://github.com/null8626/decancer.git --depth 1 | ||
$ cd ./decancer/bindings/java | ||
$ unzip ./bin/bindings.zip -d ./bin | ||
$ chmod +x ./gradlew | ||
$ ./gradlew build --warning-mode all | ||
``` | ||
</details> | ||
<details> | ||
<summary><b>C/C++</b></summary> | ||
@@ -107,21 +154,35 @@ | ||
- [Library header file](https://raw.githubusercontent.com/null8626/decancer/v2.0.2/bindings/native/decancer.h) | ||
- [Download for 64-bit Windows MSVC (Windows 7+)](https://github.com/null8626/decancer/releases/download/v2.0.2/decancer-x86_64-pc-windows-msvc.zip) | ||
- [Download for 32-bit Windows MSVC (Windows 7+)](https://github.com/null8626/decancer/releases/download/v2.0.2/decancer-i686-pc-windows-msvc.zip) | ||
- [Download for ARM64 Windows MSVC](https://github.com/null8626/decancer/releases/download/v2.0.2/decancer-aarch64-pc-windows-msvc.zip) | ||
- [Download for 64-bit macOS (10.7+, Lion+)](https://github.com/null8626/decancer/releases/download/v2.0.2/decancer-x86_64-apple-darwin.zip) | ||
- [Download for ARM64 macOS (11.0+, Big Sur+)](https://github.com/null8626/decancer/releases/download/v2.0.2/decancer-aarch64-apple-darwin.zip) | ||
- [Download for 64-bit Linux (kernel 3.2+, glibc 2.17+)](https://github.com/null8626/decancer/releases/download/v2.0.2/decancer-x86_64-unknown-linux-gnu.zip) | ||
- [Download for 64-bit Linux with MUSL](https://github.com/null8626/decancer/releases/download/v2.0.2/decancer-x86_64-unknown-linux-musl.zip) | ||
- [Download for ARM64 Linux (kernel 4.1, glibc 2.17+)](https://github.com/null8626/decancer/releases/download/v2.0.2/decancer-aarch64-unknown-linux-gnu.zip) | ||
- [Download for ARM64 Linux with MUSL](https://github.com/null8626/decancer/releases/download/v2.0.2/decancer-aarch64-unknown-linux-musl.zip) | ||
- [Download for ARMv7 Linux, hardfloat (kernel 3.2, glibc 2.17)](https://github.com/null8626/decancer/releases/download/v2.0.2/decancer-armv7-unknown-linux-gnueabihf.zip) | ||
- [Download for ARM64 macOS (11.0+, Big Sur+)](https://github.com/null8626/decancer/releases/download/v3.0.0/decancer-aarch64-apple-darwin.zip) | ||
- [Download for ARM64 iOS](https://github.com/null8626/decancer/releases/download/v3.0.0/decancer-aarch64-apple-ios.zip) | ||
- [Download for Apple iOS Simulator on ARM6](https://github.com/null8626/decancer/releases/download/v3.0.0/decancer-aarch64-apple-ios-sim.zip) | ||
- [Download for ARM64 Android](https://github.com/null8626/decancer/releases/download/v3.0.0/decancer-aarch64-linux-android.zip) | ||
- [Download for ARM64 Windows MSVC](https://github.com/null8626/decancer/releases/download/v3.0.0/decancer-aarch64-pc-windows-msvc.zip) | ||
- [Download for ARM64 Linux (kernel 4.1, glibc 2.17+)](https://github.com/null8626/decancer/releases/download/v3.0.0/decancer-aarch64-unknown-linux-gnu.zip) | ||
- [Download for ARM64 Linux with MUSL](https://github.com/null8626/decancer/releases/download/v3.0.0/decancer-aarch64-unknown-linux-musl.zip) | ||
- [Download for ARMv6 Linux (kernel 3.2, glibc 2.17)](https://github.com/null8626/decancer/releases/download/v3.0.0/decancer-arm-unknown-linux-gnueabi.zip) | ||
- [Download for ARMv5TE Linux (kernel 4.4, glibc 2.23)](https://github.com/null8626/decancer/releases/download/v3.0.0/decancer-armv5te-unknown-linux-gnueabi.zip) | ||
- [Download for ARMv7-A Android](https://github.com/null8626/decancer/releases/download/v3.0.0/decancer-armv7-linux-androideabi.zip) | ||
- [Download for ARMv7-A Linux (kernel 4.15, glibc 2.27)](https://github.com/null8626/decancer/releases/download/v3.0.0/decancer-armv7-unknown-linux-gnueabi.zip) | ||
- [Download for ARMv7-A Linux, hardfloat (kernel 3.2, glibc 2.17)](https://github.com/null8626/decancer/releases/download/v3.0.0/decancer-armv7-unknown-linux-gnueabihf.zip) | ||
- [Download for 32-bit Linux w/o SSE (kernel 3.2, glibc 2.17)](https://github.com/null8626/decancer/releases/download/v3.0.0/decancer-i586-unknown-linux-gnu.zip) | ||
- [Download for 32-bit MSVC (Windows 7+)](https://github.com/null8626/decancer/releases/download/v3.0.0/decancer-i686-pc-windows-msvc.zip) | ||
- [Download for 32-bit FreeBSD](https://github.com/null8626/decancer/releases/download/v3.0.0/decancer-i686-unknown-freebsd.zip) | ||
- [Download for 32-bit Linux (kernel 3.2+, glibc 2.17+)](https://github.com/null8626/decancer/releases/download/v3.0.0/decancer-i686-unknown-linux-gnu.zip) | ||
- [Download for PPC64LE Linux (kernel 3.10, glibc 2.17)](https://github.com/null8626/decancer/releases/download/v3.0.0/decancer-powerpc64le-unknown-linux-gnu.zip) | ||
- [Download for RISC-V Linux (kernel 4.20, glibc 2.29)](https://github.com/null8626/decancer/releases/download/v3.0.0/decancer-riscv64gc-unknown-linux-gnu.zip) | ||
- [Download for S390x Linux (kernel 3.2, glibc 2.17)](https://github.com/null8626/decancer/releases/download/v3.0.0/decancer-s390x-unknown-linux-gnu.zip) | ||
- [Download for SPARC Solaris 11, illumos](https://github.com/null8626/decancer/releases/download/v3.0.0/decancer-sparcv9-sun-solaris.zip) | ||
- [Download for Thumb2-mode ARMv7-A Linux with NEON (kernel 4.4, glibc 2.23)](https://github.com/null8626/decancer/releases/download/v3.0.0/decancer-thumbv7neon-unknown-linux-gnueabihf.zip) | ||
- [Download for 64-bit macOS (10.12+, Sierra+)](https://github.com/null8626/decancer/releases/download/v3.0.0/decancer-x86_64-apple-darwin.zip) | ||
- [Download for 64-bit iOS](https://github.com/null8626/decancer/releases/download/v3.0.0/decancer-x86_64-apple-ios.zip) | ||
- [Download for 64-bit MSVC (Windows 7+)](https://github.com/null8626/decancer/releases/download/v3.0.0/decancer-x86_64-pc-windows-msvc.zip) | ||
- [Download for 64-bit FreeBSD](https://github.com/null8626/decancer/releases/download/v3.0.0/decancer-x86_64-unknown-freebsd.zip) | ||
- [Download for 64-bit illumos](https://github.com/null8626/decancer/releases/download/v3.0.0/decancer-x86_64-unknown-illumos.zip) | ||
- [Download for 64-bit Linux (kernel 3.2+, glibc 2.17+)](https://github.com/null8626/decancer/releases/download/v3.0.0/decancer-x86_64-unknown-linux-gnu.zip) | ||
- [Download for 64-bit Linux with MUSL](https://github.com/null8626/decancer/releases/download/v3.0.0/decancer-x86_64-unknown-linux-musl.zip) | ||
### Building from source | ||
Prerequisites: | ||
Building from source requires [Rust v1.64 or later](https://rustup.rs/). | ||
- [Git](https://git-scm.com/) | ||
- [Rust v1.64 or later](https://rustup.rs/) | ||
```console | ||
@@ -145,3 +206,3 @@ $ git clone https://github.com/null8626/decancer.git --depth 1 | ||
```rust | ||
let cured = decancer::cure("vοΌ₯β‘π π½πΕβο½ Ε£δΉππ£").unwrap(); | ||
let cured = decancer::cure!("vοΌ₯β‘π π½πΕβο½ Ε£δΉππ£").unwrap(); | ||
@@ -158,3 +219,3 @@ assert_eq!(cured, "very funny text"); | ||
```js | ||
const assert = require('node:assert') | ||
const assert = require('assert') | ||
const cured = decancer('vοΌ₯β‘π π½πΕβο½ Ε£δΉππ£') | ||
@@ -196,3 +257,3 @@ | ||
<script type="module"> | ||
import init from 'https://cdn.jsdelivr.net/gh/null8626/decancer@v2.0.2/bindings/wasm/bin/decancer.min.js' | ||
import init from 'https://cdn.jsdelivr.net/gh/null8626/decancer@v3.0.0/bindings/wasm/bin/decancer.min.js' | ||
@@ -219,2 +280,23 @@ const decancer = await init() | ||
<details> | ||
<summary><b>Java</b></summary> | ||
```java | ||
import com.github.null8626.decancer.CuredString; | ||
public class Program { | ||
public static void main(String[] args) { | ||
final CuredString cured = new CuredString("vοΌ₯β‘π π½πΕβο½ Ε£δΉππ£"); | ||
assert cured.equals("very funny text"); | ||
assert cured.contains("funny"); | ||
System.out.println(cured.toString()); | ||
cured.destroy(); | ||
} | ||
} | ||
``` | ||
</details> | ||
<details> | ||
<summary><b>C/C++</b></summary> | ||
@@ -265,3 +347,3 @@ | ||
cured = decancer_cure(string, sizeof(string), &error_code); | ||
cured = decancer_cure(string, sizeof(string), DECANCER_OPTION_DEFAULT, &error_code); | ||
@@ -301,4 +383,40 @@ if (cured == NULL) | ||
## Compatibility | ||
Decancer is supported in the following platforms: | ||
Platform name | C/C++/Rust | Java | JavaScript | ||
---- | ---- | ---- | ---- | ||
ARM64 macOS (11.0+, Big Sur+) | β | β | β | | ||
ARM64 iOS | β | | | | ||
Apple iOS Simulator on ARM6 | β | | | | ||
ARM64 Android | β | | β | | ||
ARM64 Windows MSVC | β | β | β | | ||
ARM64 Linux (kernel 4.1, glibc 2.17+) | β | β | β | | ||
ARM64 Linux with MUSL | β | β | β | | ||
ARMv6 Linux (kernel 3.2, glibc 2.17) | β | β | | | ||
ARMv5TE Linux (kernel 4.4, glibc 2.23) | β | β | | | ||
ARMv7-A Android | β | | β | | ||
ARMv7-A Linux (kernel 4.15, glibc 2.27) | β | β | | | ||
ARMv7-A Linux, hardfloat (kernel 3.2, glibc 2.17) | β | β | β | | ||
32-bit Linux w/o SSE (kernel 3.2, glibc 2.17) | β | | | | ||
32-bit MSVC (Windows 7+) | β | β | β | | ||
32-bit FreeBSD | β | β | | | ||
32-bit Linux (kernel 3.2+, glibc 2.17+) | β | β | | | ||
PPC64LE Linux (kernel 3.10, glibc 2.17) | β | | | | ||
RISC-V Linux (kernel 4.20, glibc 2.29) | β | β | | | ||
S390x Linux (kernel 3.2, glibc 2.17) | β | | | | ||
SPARC Solaris 11, illumos | β | | | | ||
Thumb2-mode ARMv7-A Linux with NEON (kernel 4.4, glibc 2.23) | β | | | | ||
64-bit macOS (10.12+, Sierra+) | β | β | β | | ||
64-bit iOS | β | | | | ||
64-bit MSVC (Windows 7+) | β | β | β | | ||
64-bit FreeBSD | β | β | | | ||
64-bit illumos | β | | | | ||
64-bit Linux (kernel 3.2+, glibc 2.17+) | β | β | β | | ||
64-bit Linux with MUSL | β | β | β | | ||
## Contributing | ||
Please read [`CONTRIBUTING.md`](https://github.com/null8626/decancer/blob/main/CONTRIBUTING.md) for newbie contributors who want to contribute! |
@@ -48,2 +48,4 @@ 'use strict' | ||
let binding | ||
try { | ||
@@ -57,7 +59,12 @@ const data = PLATFORMS[process.platform][process.arch] | ||
module.exports = getBinding( | ||
binding = getBinding( | ||
typeof data === 'string' | ||
? data | ||
: `${data.name}-${data.musl && isMusl() ? 'musl' : 'gnu'}` | ||
).decancer | ||
) | ||
module.exports = Object.assign(binding.cure, { | ||
options: binding.options, | ||
format: binding.format | ||
}) | ||
} catch (err) { | ||
@@ -64,0 +71,0 @@ console.error( |
@@ -9,2 +9,31 @@ export class CuredString { | ||
export default function (input: string): CuredString | ||
export type Options = { | ||
retainCapitalization?: boolean | ||
disableBidi?: boolean | ||
retainDiacritics?: boolean | ||
retainGreek?: boolean | ||
retainCyrillic?: boolean | ||
retainHebrew?: boolean | ||
retainArabic?: boolean | ||
retainDevanagari?: boolean | ||
retainBengali?: boolean | ||
retainArmenian?: boolean | ||
retainGujarati?: boolean | ||
retainTamil?: boolean | ||
retainThai?: boolean | ||
retainLao?: boolean | ||
retainBurmese?: boolean | ||
retainKhmer?: boolean | ||
retainMongolian?: boolean | ||
retainChinese?: boolean | ||
retainJapanese?: boolean | ||
retainKorean?: boolean | ||
retainBraille?: boolean | ||
retainEmojis?: boolean | ||
pureHomoglyph?: boolean | ||
} | ||
export default function (input: string, options?: Options | number): CuredString | ||
export function options(options?: Options): number | ||
export function format(input: string): string |
20590
97
410