From: edwin Date: Fri, 5 May 2006 13:56:35 +0000 (+0000) Subject: * src/vm/utf8.c, src/vm/utf8.h (utf_bytes): New function. X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=511fde7f7add8e8548d763b6086956d44e1bd28c;p=cacao.git * src/vm/utf8.c, src/vm/utf8.h (utf_bytes): New function. Use this function to query the number of octets of a utf string. This function will become the correct replacement for the old utf_strlen in most places. The calling code will have to be reviewed for that, however, and it will also require fixing utf_strcat, utf_sprint, and so on, to do the right thing. --- diff --git a/src/vm/utf8.c b/src/vm/utf8.c index 0c854744e..89c9d4600 100644 --- a/src/vm/utf8.c +++ b/src/vm/utf8.c @@ -30,7 +30,7 @@ Andreas Krall Christian Thalinger - $Id: utf8.c 4872 2006-05-05 13:48:25Z edwin $ + $Id: utf8.c 4873 2006-05-05 13:56:35Z edwin $ */ @@ -790,6 +790,24 @@ u2 utf_nextu2(char **utf_ptr) } +/* utf_bytes ******************************************************************* + + Determine number of bytes (aka. octets) in the utf string. + + IN: + u............utf string + + OUT: + The number of octets of this utf string. + There is _no_ terminating zero included in this count. + +*******************************************************************************/ + +u4 utf_bytes(utf *u) +{ + return u->blength; +} + /* utf_get_number_of_u2s ******************************************************* Determine number of UTF-16 u2s in the utf string. diff --git a/src/vm/utf8.h b/src/vm/utf8.h index a470d4dca..600fdfa48 100644 --- a/src/vm/utf8.h +++ b/src/vm/utf8.h @@ -28,7 +28,7 @@ Changes: - $Id: utf8.h 4872 2006-05-05 13:48:25Z edwin $ + $Id: utf8.h 4873 2006-05-05 13:56:35Z edwin $ */ @@ -183,6 +183,9 @@ utf *utf_new_u2(u2 *unicodedata, u4 unicodelength, bool isclassname); utf *utf_new_char(const char *text); utf *utf_new_char_classname(const char *text); +/* get number of bytes */ +u4 utf_bytes(utf *u); + /* get next unicode character of a utf-string */ u2 utf_nextu2(char **utf);