按字素群分组,返回 UTF-16 起始位置、Emoji 状态以及各码位的 Unicode 类别与不可见标记。 访问类别:匿名 API,可携带 Token 使用独立额度
请求参数
_formatquery- 响应格式为 json 或 text;_format=svg 返回 JSON。plain 是 text 的别名。未识别的值继续按 Accept 协商。
- string · 可选:json、text
_colorquery- 控制 text 响应的 ANSI 颜色。0、false、off、no 关闭;省略或其他值保留。
- string · 可选:0、false、off、no
请求体
application/jsontext必填- string · 最长:65536 字符
裸值请求体
可直接发送 text 的 JSON 值。需要传入可选字段时,使用 JSON 对象。
响应
application/json
{
"type": "object",
"properties": {
"segments": {
"type": "array",
"items": {
"type": "object",
"properties": {
"index": {
"type": "number"
},
"segment": {
"type": "string"
},
"emoji": {
"type": "boolean"
},
"points": {
"type": "array",
"items": {
"type": "object",
"properties": {
"character": {
"type": "string"
},
"codePoint": {
"type": "string"
},
"category": {
"type": "string"
},
"invisible": {
"type": "boolean"
},
"name": {
"type": "string"
}
},
"required": [
"character",
"codePoint",
"category",
"invisible",
"name"
]
}
}
},
"required": [
"index",
"segment",
"emoji",
"points"
]
}
}
},
"required": [
"segments"
]
}application/json
{
"type": "object",
"properties": {
"error": {
"type": "object",
"properties": {
"code": {
"type": "string"
},
"message": {
"type": "string"
},
"issues": {
"type": "array",
"items": {
"type": "object",
"properties": {
"location": {
"type": "string",
"enum": [
"body",
"query",
"path",
"header"
]
},
"field": {
"type": "string"
},
"code": {
"type": "string"
},
"message": {
"type": "string"
}
},
"required": [
"location",
"field",
"code",
"message"
]
}
}
},
"required": [
"code",
"message"
]
}
},
"required": [
"error"
]
}application/json
{
"type": "object",
"properties": {
"error": {
"type": "object",
"properties": {
"code": {
"type": "string"
},
"message": {
"type": "string"
},
"issues": {
"type": "array",
"items": {
"type": "object",
"properties": {
"location": {
"type": "string",
"enum": [
"body",
"query",
"path",
"header"
]
},
"field": {
"type": "string"
},
"code": {
"type": "string"
},
"message": {
"type": "string"
}
},
"required": [
"location",
"field",
"code",
"message"
]
}
}
},
"required": [
"code",
"message"
]
}
},
"required": [
"error"
]
}application/json
{
"type": "object",
"properties": {
"error": {
"type": "object",
"properties": {
"code": {
"type": "string"
},
"message": {
"type": "string"
},
"issues": {
"type": "array",
"items": {
"type": "object",
"properties": {
"location": {
"type": "string",
"enum": [
"body",
"query",
"path",
"header"
]
},
"field": {
"type": "string"
},
"code": {
"type": "string"
},
"message": {
"type": "string"
}
},
"required": [
"location",
"field",
"code",
"message"
]
}
}
},
"required": [
"code",
"message"
]
}
},
"required": [
"error"
]
}application/json
{
"type": "object",
"properties": {
"error": {
"type": "object",
"properties": {
"code": {
"type": "string"
},
"message": {
"type": "string"
},
"issues": {
"type": "array",
"items": {
"type": "object",
"properties": {
"location": {
"type": "string",
"enum": [
"body",
"query",
"path",
"header"
]
},
"field": {
"type": "string"
},
"code": {
"type": "string"
},
"message": {
"type": "string"
}
},
"required": [
"location",
"field",
"code",
"message"
]
}
}
},
"required": [
"code",
"message"
]
}
},
"required": [
"error"
]
}application/json
{
"type": "object",
"properties": {
"error": {
"type": "object",
"properties": {
"code": {
"type": "string"
},
"message": {
"type": "string"
},
"issues": {
"type": "array",
"items": {
"type": "object",
"properties": {
"location": {
"type": "string",
"enum": [
"body",
"query",
"path",
"header"
]
},
"field": {
"type": "string"
},
"code": {
"type": "string"
},
"message": {
"type": "string"
}
},
"required": [
"location",
"field",
"code",
"message"
]
}
}
},
"required": [
"code",
"message"
]
}
},
"required": [
"error"
]
}application/json
{
"type": "object",
"properties": {
"error": {
"type": "object",
"properties": {
"code": {
"type": "string"
},
"message": {
"type": "string"
},
"issues": {
"type": "array",
"items": {
"type": "object",
"properties": {
"location": {
"type": "string",
"enum": [
"body",
"query",
"path",
"header"
]
},
"field": {
"type": "string"
},
"code": {
"type": "string"
},
"message": {
"type": "string"
}
},
"required": [
"location",
"field",
"code",
"message"
]
}
}
},
"required": [
"code",
"message"
]
}
},
"required": [
"error"
]
}application/json
{
"type": "object",
"properties": {
"error": {
"type": "object",
"properties": {
"code": {
"type": "string"
},
"message": {
"type": "string"
},
"issues": {
"type": "array",
"items": {
"type": "object",
"properties": {
"location": {
"type": "string",
"enum": [
"body",
"query",
"path",
"header"
]
},
"field": {
"type": "string"
},
"code": {
"type": "string"
},
"message": {
"type": "string"
}
},
"required": [
"location",
"field",
"code",
"message"
]
}
}
},
"required": [
"code",
"message"
]
}
},
"required": [
"error"
]
}响应示例
成功响应
printf '%s' '"A\u200B👩💻\u3000\uFEFF"' | curl -sS --json @- https://oit.sh/reference/charactersHTTP 200
content-type: application/json
content-encoding: gzip
cache-control: no-store
{
"segments": [
{
"index": 0,
"segment": "A",
"emoji": false,
"points": [
{
"character": "A",
"codePoint": "U+0041",
"category": "Lu",
"invisible": false,
"name": ""
}
]
},
{
"index": 1,
"segment": "",
"emoji": false,
"points": [
{
"character": "",
"codePoint": "U+200B",
"category": "Cf",
"invisible": true,
"name": "零宽空格"
}
]
},
{
"index": 2,
"segment": "👩💻",
"emoji": true,
"points": [
{
"character": "👩",
"codePoint": "U+1F469",
"category": "So",
"invisible": false,
"name": ""
},
{
"character": "",
"codePoint": "U+200D",
"category": "Cf",
"invisible": true,
"name": "零宽连接符"
},
{
"character": "💻",
"codePoint": "U+1F4BB",
"category": "So",
"invisible": false,
"name": ""
}
]
},
{
"index": 7,
"segment": " ",
"emoji": false,
"points": [
{
"character": " ",
"codePoint": "U+3000",
"category": "Zs",
"invisible": true,
"name": "全角空格"
}
]
},
{
"index": 8,
"segment": "",
"emoji": false,
"points": [
{
"character": "",
"codePoint": "U+FEFF",
"category": "Cf",
"invisible": true,
"name": "BOM"
}
]
}
]
}错误示例
curl -sS --json '{}' https://oit.sh/reference/charactersHTTP 400
content-type: application/json
content-encoding: gzip
cache-control: no-store
{
"error": {
"code": "INVALID_INPUT",
"message": "参数无效",
"issues": [
{
"location": "body",
"field": "text",
"code": "invalid_type",
"message": "需要 字符串 类型"
}
]
}
}curl 访问示例
curl、wget、HTTPie 默认得到 text/plain。示例展示纯文本输出。
命令与输出
printf '%s' '"A\u200B👩💻\u3000\uFEFF"' | curl -sS --json @- 'https://oit.sh/reference/characters?_color=0&_format=text'HTTP 200
content-type: text/plain; charset=utf-8
content-encoding: gzip
cache-control: no-store
segments:
-
index: 0
segment: A
emoji: false
points:
-
character: A
codePoint: U+0041
category: Lu
invisible: false
name:
-
index: 1
segment:
emoji: false
points:
-
character:
codePoint: U+200B
category: Cf
invisible: true
name: 零宽空格
-
index: 2
segment: 👩💻
emoji: true
points:
-
character: 👩
codePoint: U+1F469
category: So
invisible: false
name:
-
character:
codePoint: U+200D
category: Cf
invisible: true
name: 零宽连接符
-
character: 💻
codePoint: U+1F4BB
category: So
invisible: false
name:
-
index: 7
segment:
emoji: false
points:
-
character:
codePoint: U+3000
category: Zs
invisible: true
name: 全角空格
-
index: 8
segment:
emoji: false
points:
-
character:
codePoint: U+FEFF
category: Cf
invisible: true
name: BOM
在线调试
curl -X POST 'https://oit.sh/reference/characters' \
-H 'Content-Type: application/json' \
--data-raw '{"text":"A👩💻 "}'响应
等待发送请求