diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2024-05-27 11:29:39 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2024-05-27 11:29:39 -0300 |
commit | 814213b65fa4ab2b1a7216d06f68a6f3df89efcd (patch) | |
tree | 899a187277f8645f9bc0b48ae55be4c31a61ae39 /manual | |
parent | cbdf4969ec425f1df1ade358425c0bf0bf811d83 (diff) | |
download | lua-814213b65fa4ab2b1a7216d06f68a6f3df89efcd.tar.gz lua-814213b65fa4ab2b1a7216d06f68a6f3df89efcd.tar.bz2 lua-814213b65fa4ab2b1a7216d06f68a6f3df89efcd.zip |
utf8.offset returns also final position of character
'utf8.offset' returns two values: the initial and the final position
of the given character.
Diffstat (limited to 'manual')
-rw-r--r-- | manual/manual.of | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/manual/manual.of b/manual/manual.of index f830b01c..359bd166 100644 --- a/manual/manual.of +++ b/manual/manual.of | |||
@@ -7958,21 +7958,27 @@ returns @fail plus the position of the first invalid byte. | |||
7958 | 7958 | ||
7959 | @LibEntry{utf8.offset (s, n [, i])| | 7959 | @LibEntry{utf8.offset (s, n [, i])| |
7960 | 7960 | ||
7961 | Returns the position (in bytes) where the encoding of the | 7961 | Returns the the position of the @id{n}-th character of @id{s} |
7962 | @id{n}-th character of @id{s} | 7962 | (counting from byte position @id{i}) as two integers: |
7963 | (counting from position @id{i}) starts. | 7963 | The index (in bytes) where its encoding starts and the |
7964 | index (in bytes) where it ends. | ||
7965 | |||
7966 | If the specified character is right after the end of @id{s}, | ||
7967 | the function behaves as if there was a @Char{\0} there. | ||
7968 | If the specified character is neither in the subject | ||
7969 | nor right after its end, | ||
7970 | the function returns @fail. | ||
7971 | |||
7964 | A negative @id{n} gets characters before position @id{i}. | 7972 | A negative @id{n} gets characters before position @id{i}. |
7965 | The default for @id{i} is 1 when @id{n} is non-negative | 7973 | The default for @id{i} is 1 when @id{n} is non-negative |
7966 | and @T{#s + 1} otherwise, | 7974 | and @T{#s + 1} otherwise, |
7967 | so that @T{utf8.offset(s, -n)} gets the offset of the | 7975 | so that @T{utf8.offset(s, -n)} gets the offset of the |
7968 | @id{n}-th character from the end of the string. | 7976 | @id{n}-th character from the end of the string. |
7969 | If the specified character is neither in the subject | ||
7970 | nor right after its end, | ||
7971 | the function returns @fail. | ||
7972 | 7977 | ||
7973 | As a special case, | 7978 | As a special case, |
7974 | when @id{n} is 0 the function returns the start of the encoding | 7979 | when @id{n} is 0 the function returns the start and end |
7975 | of the character that contains the @id{i}-th byte of @id{s}. | 7980 | of the encoding of the character that contains the |
7981 | @id{i}-th byte of @id{s}. | ||
7976 | 7982 | ||
7977 | This function assumes that @id{s} is a valid UTF-8 string. | 7983 | This function assumes that @id{s} is a valid UTF-8 string. |
7978 | 7984 | ||