From 0c8a78a426e48b9adf19ff75c5d8c7cb112e91dd Mon Sep 17 00:00:00 2001 From: Stanislav Horacek Date: Wed, 21 Jan 2015 18:09:50 +0100 Subject: add examples for functions dealing with DBCS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit by Jesper Hertel (jesper.hertel@gmail.com) see http://listarchives.libreoffice.org/global/l10n/msg08594.html Change-Id: I2c281aab12ba9c10184658eff9837d39e397af09 Reviewed-on: https://gerrit.libreoffice.org/14092 Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- source/text/scalc/01/04060110.xhp | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) (limited to 'source') diff --git a/source/text/scalc/01/04060110.xhp b/source/text/scalc/01/04060110.xhp index e55d4b903d..5afc866342 100644 --- a/source/text/scalc/01/04060110.xhp +++ b/source/text/scalc/01/04060110.xhp @@ -331,8 +331,12 @@ LEFTB("Text"; Number_bytes) Text is the text where the initial partial words are to be determined. Number_bytes (optional) specifies the number of characters you want LEFTB to extract, based on bytes. If this parameter is not defined, one character is returned. - Example - =LEFTB("output";3) returns “out”. + Examples + LEFTB("中国";1) returns " " (1 byte is only half a DBCS character and a space character is returned instead). + LEFTB("中国";2) returns "中" (2 bytes constitute one complete DBCS character). + LEFTB("中国";3) returns "中 " (3 bytes constitute one DBCS character and a half; the last character returned is therefore a space character). + LEFTB("中国";4) returns "中国" (4 bytes constitute two complete DBCS characters). + LEFTB("office";3) returns "off" (3 non-DBCS characters each consisting of 1 byte).
LEN function @@ -362,7 +366,10 @@ Syntax LENB("Text") Text is the text whose length is to be determined. - Example + Examples + LENB("中") returns 2 (1 DBCS character consisting of 2 bytes). + LENB("中国") returns 4 (2 DBCS characters each consisting of 2 bytes). + LENB("office") returns 6 (6 non-DBCS characters each consisting of 1 byte). =LENB("Good Afternoon") returns 14. @@ -417,9 +424,18 @@ Text is the text containing the characters to extract. Start is the position of the first character in the text to extract. Number_bytes specifies the number of characters MIDB will return from text, in bytes. - Example - - =MIDB("office";2;2) returns ff. + Examples + MIDB("中国";1;0) returns "" (0 bytes is always an empty string). + MIDB("中国";1;1) returns " " (1 byte is only half a DBCS character and therefore the result is a space character). + MIDB("中国";1;2) returns "中" (2 bytes constitute one complete DBCS character). + MIDB("中国";1;3) returns "中 " (3 bytes constitute one and a half DBCS character; the last byte results in a space character). + MIDB("中国";1;4) returns "中国" (4 bytes constitute two complete DBCS characters). + MIDB("中国";2;1) returns " " (byte position 2 is not at the beginning of a character in a DBCS string; 1 space character is returned). + MIDB("中国";2;2) returns " " (byte position 2 points to the last half of the first character in the DBCS string; the 2 bytes asked for therefore constitutes the last half of the first character and the first half of the second character in the string; 2 space characters are therefore returned). + MIDB("中国";2;3) returns " 国" (byte position 2 is not at the beginning of a character in a DBCS string; a space character is returned for byte position 2). + MIDB("中国";3;1) returns " " (byte position 3 is at the beginning of a character in a DBCS string, but 1 byte is only half a DBCS character and a space character is therefore returned instead). + MIDB("中国";3;2) returns "国" (byte position 3 is at the beginning of a character in a DBCS string, and 2 bytes constitute one DBCS character). + MIDB("office";2;3) returns "ffi" (byte position 2 is at the beginning of a character in a non-DBCS string, and 3 bytes of a non-DBCS string constitute 3 characters).
PROPER function @@ -511,9 +527,12 @@ RIGHTB("Text"; Number_bytes) Text is the text of which the right part is to be determined. Number_bytes (optional) specifies the number of characters you want RIGHTB to extract, based on bytes. - Example - - =RIGHTB("Sun";2) returns un. + Examples + RIGHTB("中国";1) returns " " (1 byte is only half a DBCS character and a space character is returned instead). + RIGHTB("中国";2) returns "国" (2 bytes constitute one complete DBCS character). + RIGHTB("中国";3) returns " 国" (3 bytes constitute one half DBCS character and one whole DBCS character; a space is returned for the first half). + RIGHTB("中国";4) returns "中国" (4 bytes constitute two complete DBCS characters). + RIGHTB("office";3) returns "ice" (3 non-DBCS characters each consisting of 1 byte).
ROMAN function -- cgit