> Discover all available pages from the documentation index: https://mastra.zisheng.pro/zh-TW/llms.txt # UnicodeNormalizer `UnicodeNormalizer` 是一種**輸入處理器**,會在訊息傳送至語言模型之前正規化 Unicode 文字,以確保格式一致,並移除可能造成問題的字元。此處理器會處理各種 Unicode 表示法並移除控制字元,也會統一空白格式。 ## 使用範例 ```typescript import { UnicodeNormalizer } from '@mastra/core/processors' const processor = new UnicodeNormalizer({ stripControlChars: true, collapseWhitespace: true, }) ``` ## 建構函式參數 **options** (`Options`): Unicode 文字正規化的設定選項 **options.stripControlChars** (`boolean`): 是否移除控制字元。啟用時,會移除 、 、 以外的控制字元 **options.preserveEmojis** (`boolean`): 是否保留 emoji。停用時,若 emoji 含有控制字元,可能會被移除 **options.collapseWhitespace** (`boolean`): 是否合併連續空白。啟用時,會將多個空格/定位字元/換行字元分別合併為單一字元 **options.trim** (`boolean`): 是否移除開頭與結尾的空白 ## 回傳值 **id** (`string`): 設為 'unicode-normalizer' 的處理器識別碼 **name** (`string`): 選用的處理器顯示名稱 **processInput** (`(args: { messages: MastraDBMessage[]; abort: (reason?: string) => never }) => MastraDBMessage[]`): 處理輸入訊息,以正規化 Unicode 文字 ## 延伸使用範例 ```typescript import { Agent } from '@mastra/core/agent' import { UnicodeNormalizer } from '@mastra/core/processors' export const agent = new Agent({ id: 'normalized-agent', name: 'normalized-agent', instructions: 'You are a helpful assistant', model: 'openai/gpt-5.6-sol', inputProcessors: [ new UnicodeNormalizer({ stripControlChars: true, preserveEmojis: true, collapseWhitespace: true, trim: true, }), ], }) ``` ## 相關資源 - [防護欄](https://mastra.zisheng.pro/zh-TW/docs/agents/guardrails)