Thanks a lot!

I've submitted the suggestions to Gerrit, where anyone is welcome to comment them:
https://gerrit.libreoffice.org/#/c/14092/

Stanislav

Dne 20.1.2015 v 02:25 Jesper Hertel napsal(a):


Here are my suggestions for examples for MIDB, LEFTB, RIGHTB and LENB.

I actually made a spreadsheet in LibreOffice Calc and tested each
expression to be absolutely sure of the results. The spreadsheet I made
can be found at [1]. I made it using the English (US) user interface and
locale.

[1]: http://www49.zippyshare.com/v/YbkWBbkZ/file.html

It turned out that invalid requests (half DBCS characters) actually do
*not* result in empty strings but rather in a *space character*.

Therefore these suggested examples and explanations.

The return values are the *actual* return values using the actual
mentioned expressions and were therefore *not* typed by hand (check the
spreadsheet if you want to see how). Note the rather subtle spaces returned.

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).

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).

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).

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).



If anyone else is curious, "中国" means China in Chinese – according to
Google Translate :-).


Jesper

--
To unsubscribe e-mail to: l10n+unsubscr...@global.libreoffice.org
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/l10n/
All messages sent to this list will be publicly archived and cannot be deleted

Reply via email to