[Function] Support utf-8 encoding in instr, locate, locate_pos, lpad, rpad (#3638)
Support utf-8 encoding for string function `instr`, `locate`, `locate_pos`, `lpad`, `rpad` and add unit test for them
This commit is contained in:
@ -31,7 +31,7 @@ under the License.
|
||||
`VARCHAR lpad(VARCHAR str, INT len, VARCHAR pad)`
|
||||
|
||||
|
||||
返回 str 中长度为 len(从首字母开始算起)的字符串。如果 len 大于 str 的长度,则在 str 的前面不断补充 pad 字符,直到该字符串的长度达到 len 为止。如果 len 小于 str 的长度,该函数相当于截断 str 字符串,只返回长度为 len 的字符串。
|
||||
返回 str 中长度为 len(从首字母开始算起)的字符串。如果 len 大于 str 的长度,则在 str 的前面不断补充 pad 字符,直到该字符串的长度达到 len 为止。如果 len 小于 str 的长度,该函数相当于截断 str 字符串,只返回长度为 len 的字符串。len 指的是字符长度而不是字节长度。
|
||||
|
||||
## example
|
||||
|
||||
|
||||
@ -0,0 +1,54 @@
|
||||
---
|
||||
{
|
||||
"title": "rpad",
|
||||
"language": "zh-CN"
|
||||
}
|
||||
---
|
||||
|
||||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
|
||||
# rpad
|
||||
## description
|
||||
### Syntax
|
||||
|
||||
`VARCHAR rpad(VARCHAR str, INT len, VARCHAR pad)`
|
||||
|
||||
|
||||
返回 str 中长度为 len(从首字母开始算起)的字符串。如果 len 大于 str 的长度,则在 str 的后面不断补充 pad 字符,直到该字符串的长度达到 len 为止。如果 len 小于 str 的长度,该函数相当于截断 str 字符串,只返回长度为 len 的字符串。len 指的是字符长度而不是字节长度。
|
||||
|
||||
## example
|
||||
|
||||
```
|
||||
mysql> SELECT rpad("hi", 5, "xy");
|
||||
+---------------------+
|
||||
| rpad('hi', 5, 'xy') |
|
||||
+---------------------+
|
||||
| hixyx |
|
||||
+---------------------+
|
||||
|
||||
mysql> SELECT rpad("hi", 1, "xy");
|
||||
+---------------------+
|
||||
| rpad('hi', 1, 'xy') |
|
||||
+---------------------+
|
||||
| h |
|
||||
+---------------------+
|
||||
```
|
||||
##keyword
|
||||
RPAD
|
||||
Reference in New Issue
Block a user