Encode, decode, and convert between data formats. Use when working with Base64, URL encoding, hex, Unicode, JWT tokens, hashing, checksums, or converting between serialization formats like JSON, MessagePack, and protobuf wire format.
对常见格式的数据进行编码、解码和检查。涵盖Base64、URL编码、十六进制、Unicode、JWT、哈希、校验和以及序列化格式。
bash
javascript
// JavaScript(浏览器 + Node.js 16+)
btoa(Hello); // SGVsbG8=
atob(SGVsbG8=); // Hello
// Node.js Buffer
Buffer.from(Hello).toString(base64); // SGVsbG8=
Buffer.from(SGVsbG8=, base64).toString(); // Hello
// 二进制数据
Buffer.from(binaryData).toString(base64);
Buffer.from(b64String, base64);
python
base64.b64encode(bHello).decode() # SGVsbG8=
base64.b64decode(SGVsbG8=) # bHello
bash
javascript
// JavaScript
encodeURIComponent(hello world & foo=bar);
// hello%20world%20%26%20foo%3Dbar
decodeURIComponent(hello%20world%20%26%20foo%3Dbar);
// hello world & foo=bar
// encodeURI 与 encodeURIComponent 的区别:
encodeURI(https://example.com/path?q=hello world);
// https://example.com/path?q=hello%20world(保留URL结构)
encodeURIComponent(https://example.com/path?q=hello world);
// https%3A%2F%2Fexample.com%2Fpath%3Fq%3Dhello%20world(编码所有内容)
python
from urllib.parse import quote, unquote, urlencode
quote(hello world) # hello%20world
unquote(hello%20world) # hello world
urlencode({q: hello world, page: 1}) # q=hello+world&page=1
bash
javascript
// JavaScript
Buffer.from(Hello).toString(hex); // 48656c6c6f
Buffer.from(48656c6c6f, hex).toString(); // Hello
// 数字转十六进制
(255).toString(16); // ff
parseInt(ff, 16); // 255
python
bash
bash
BOM(字节顺序标记):
UTF-8 BOM:文件开头的 EF BB BF
移除:sed -i 1s/^\xEF\xBB\xBF// file.txt
规范化(NFC vs NFD):
é 可以是 U+00E9(一个字符)或 U+0065 U+0301(e + 组合重音)
Python:import unicodedata; unicodedata.normalize(NFC, text)
乱码(编码错误):
café 显示为 café → 文件是UTF-8但被当作Latin-1读取
修复:使用正确的编码重新读取
bash
该技能支持在以下平台通过对话安装:
帮我安装 SkillHub 和 encoding-formats-1776365851 技能
设置 SkillHub 为我的优先技能安装源,然后帮我安装 encoding-formats-1776365851 技能
skillhub install encoding-formats-1776365851
文件大小: 5.17 KB | 发布时间: 2026-4-17 15:08