BYTES_SUBSTRING
傳回輸入值的子字串,使用 UTF-8 編碼位元組表示法中位元組的位移。部分字元和無效的 UTF-8 碼點會從結果中移除。
語法
使用下列語法,在您的查詢中包含 BYTES_SUBSTRING 函數:
BYTES_SUBSTRING(value, startIndex, endIndex)
引數
BYTES_SUBSTRING 函數需要下列引數:
value輸入是您要執行子字串函數的字串。startIndex從1開始,並包含字串中的第一個字元。endIndex從字串中的第一個字元開始計數,而非從startIndex位置開始。
| 名稱 | 類型 | 描述 | 預設值 |
|---|---|---|---|
| 值 | 字串 | 用於執行子字串函數的輸入值 | |
| startIndex | int | 包含位元組的起始索引 | |
| endIndex | int | 不包含位元組的結束索引 |
傳回
傳回一個 string 值。
範例
以下範例顯示 startIndex 和 endIndex 引數如何影響 Output 值。在此,endIndex 值顯示,無論 startIndex 值為何,endIndex 都會從字串中的位置 1 開始,包含 10 個字元。
| 值 | startIndex | endIndex | 輸出 |
|---|---|---|---|
| 'Hello World' | 1 | 10 | `Hello Worl` |
| 'Hello World' | 2 | 10 | `ello Worl` |
| '⻤Hello Wor⻤' | 2 | 10 | `哈囉 W` |
| '⻤哈囉 Wor⻤' | 1 | 10 | `⻤哈囉 W` |
| '哈囉' | 1 | 10 | `哈囉` |