Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions types/encoding-japanese/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,30 +33,30 @@ export interface ConvertStringOptions {
to: Encoding;
from?: Encoding | undefined;
type: "string";
fallback?: "html-entity" | "html-entity-hex";
fallback?: "html-entity" | "html-entity-hex" | "ignore" | "error";
bom?: boolean | string | undefined;
}

export interface ConvertArrayBufferOptions {
to: Encoding;
from?: Encoding | undefined;
type: "arraybuffer";
fallback?: "html-entity" | "html-entity-hex";
fallback?: "html-entity" | "html-entity-hex" | "ignore" | "error";
bom?: boolean | string | undefined;
}

export interface ConvertArrayOptions {
to: Encoding;
from?: Encoding | undefined;
type: "array";
fallback?: "html-entity" | "html-entity-hex";
fallback?: "html-entity" | "html-entity-hex" | "ignore" | "error";
bom?: boolean | string | undefined;
}

export interface ConvertUnknownOptions {
to: Encoding;
from?: Encoding | undefined;
fallback?: "html-entity" | "html-entity-hex";
fallback?: "html-entity" | "html-entity-hex" | "ignore" | "error";
bom?: boolean | string | undefined;
}

Expand Down
2 changes: 1 addition & 1 deletion types/encoding-japanese/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@types/encoding-japanese",
"version": "2.0.9999",
"version": "2.2.9999",
"projects": [
"https://github.com/polygonplanet/encoding.js"
],
Expand Down
26 changes: 22 additions & 4 deletions types/encoding-japanese/test/encoding-japanese-tests.cjs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,24 @@ const sjisArray4 = Encoding.convert("🐙", {
sjisArray4; // $ExpectType string
// fallback: '🐙'

const sjisArray5 = Encoding.convert("🐙", {
to: "SJIS", // to_encoding
from: "UTF8", // from_encoding
type: "string",
fallback: "ignore",
});
sjisArray5; // $ExpectType string
// fallback: ''

const sjisArray6 = Encoding.convert("🐙", {
to: "SJIS", // to_encoding
from: "UTF8", // from_encoding
type: "string",
fallback: "error",
});
sjisArray6; // $ExpectType string
// throws error: `Character cannot be represented`

const utf8String = "ã\u0081\u0093ã\u0082\u0093ã\u0081«ã\u0081¡ã\u0081¯";
const unicodeString = Encoding.convert(utf8String, {
to: "UNICODE",
Expand Down Expand Up @@ -120,7 +138,7 @@ if (isSJIS) {
// Encoding is SJIS'
}

const sjisArray5 = [
const sjisArray7 = [
130,
177,
130,
Expand All @@ -145,7 +163,7 @@ const sjisArray5 = [
230,
];

const encoded = Encoding.urlEncode(sjisArray5); // $ExpectType string
const encoded = Encoding.urlEncode(sjisArray7); // $ExpectType string
// encoded: '%82%B1%82%F1%82%C9%82%BF%82%CD%81A%82%D9%82%B0%81%99%82%D2%82%E6'

const decoded = Encoding.urlDecode(encoded); // $ExpectType number[]
Expand All @@ -154,8 +172,8 @@ const decoded = Encoding.urlDecode(encoded); // $ExpectType number[]
// 65, 130, 217, 130, 176, 129, 153, 130, 210, 130, 230
// ]

const sjisArray6 = [130, 177, 130, 241, 130, 201, 130, 191, 130, 205];
const encoded2 = Encoding.base64Encode(sjisArray6); // $ExpectType string
const sjisArray8 = [130, 177, 130, 241, 130, 201, 130, 191, 130, 205];
const encoded2 = Encoding.base64Encode(sjisArray8); // $ExpectType string
// encoded2: 'grGC8YLJgr+CzQ=='

const decoded2 = Encoding.base64Decode(encoded2); // $ExpectType number[]
Expand Down