Skip to main contentModule encoding
Source - LastChunkHandling 🔒
- B64_CHARS 🔒
- base64_to_bytes 🔒
- base64 文字列をバイト列へデコードする共通処理(
atob/Uint8Array.fromBase64 で共有)。
未知の文字(改行等)は無視する簡略実装。 - boot_seed 🔒
- 乱数の種(起動ごとに変える)。現在時刻(秒)と起動からの経過(マイクロ秒)を混ぜる。
- bytes_to_base64 🔒
- バイト列を base64 文字列へエンコードする共通処理(
btoa/Uint8Array.prototype.toBase64 で共有)。 - bytes_to_hex 🔒
- バイト列を小文字16進文字列へエンコードする(
Uint8Array.prototype.toHex)。 - decode_base64_char 🔒
- decode_base64_into 🔒
- forgiving_base64_decode 🔒
- WHATWG の forgiving-base64 decode(
atob)。空白を除き、末尾の = を外し、長さ・文字が不正なら None。 - hex_to_bytes 🔒
- 16進文字列をバイト列へデコードする(
Uint8Array.fromHex)。奇数長や不正文字は None。 - is_ascii_ws 🔒
- js_decode_uri 🔒
- js_decode_uri_component 🔒
- js_encode_uri 🔒
- js_encode_uri_component 🔒
- js_escape 🔒
escape(str)(Annex B.2.1.1。ES6 で非推奨だが encodeURI 系登場以前からの
遺産として実務コードになお残る)が丸ごと未対応だった。仕様は UTF-16
コード単位ベースだが、この処理系の文字列は UTF-8(Rust String)のため
Unicode スカラー値(char)単位で近似する(BMP 外文字のサロゲートペア
分割は考慮しない、他の Unicode 境界処理と同水準の簡略化)。- js_unescape 🔒
unescape(str)(Annex B.2.1.2)。escape の逆変換。%XX/%uXXXX を復元し、
どちらの形にも一致しない % はそのまま素通しする(仕様どおり)。- next_rand_u64 🔒
- parse_base64_options 🔒
- percent_decode 🔒
%XX を1バイトへ復元する共通デコーダ。plus_as_space が true の場合のみ
+ を空白として扱う(form-urlencoded 用。encodeURIComponent 系では false)。- percent_encode_component 🔒
encodeURIComponent 相当。未エスケープ文字は RFC3986 unreserved + !'()*。- percent_encode_uri 🔒
encodeURI 相当。encodeURIComponent の非エスケープ集合に加え、URI 予約文字
(;/?:@&=+$,#) も未エスケープのまま残す(コンポーネントではなくURI全体用のため)。- ta_from_base64 🔒
Uint8Array.fromBase64(str)(ES2024/2025 静的メソッド)。- ta_from_hex 🔒
Uint8Array.fromHex(str)(ES2024/2025 静的メソッド)。不正な16進文字列は例外を投げる。- ta_set_from_base64 🔒
Uint8Array.prototype.setFromBase64(str [, options])(ES2024/2025)。- ta_set_from_hex 🔒
Uint8Array.prototype.setFromHex(str)(ES2024/2025)。不正な16進文字列は例外を投げる。- ta_to_base64 🔒
Uint8Array.prototype.toBase64()(ES2024/2025)。- ta_to_bytes 🔒
- TypedArray インスタンスの要素を u8 バイト列として取り出す(Uint8Array 専用機能で使用)。
- ta_to_hex 🔒
Uint8Array.prototype.toHex()(ES2024/2025)。- ta_write_bytes_into 🔒
- デコードしたバイト列を既存の
this(Uint8Array)の先頭から上書きし、
{ read, written }(read は入力文字列の消費文字数、written は書き込んだ
バイト数)を返す共通処理。setFromBase64/setFromHex で共有する。
toBase64/toHex(読み取り)と fromBase64/fromHex(新規生成)は
実装済みだったが、既存バッファへインプレースで書き込む対になる
setFromBase64/setFromHex(ES2024/2025)が丸ごと未対応だった。 - uri_decode 🔒
- 仕様の Decode(ECMA-262 19.2.6.1.2)。
%XX が壊れている・UTF-8 として読めないなら None(URIError)。
reserved の文字(decodeURI の ;/?:@&=+$,#)に当たる %XX は元のまま残す。
【2026-11-16】以前は percent_decode の寛容な版を使い、decodeURIComponent("%") が例外にならず、
decodeURI("%2f") が / になっていた。
- Base64DecodeResult 🔒