Re: [xml] iterating an UTF-8 string (xmlChar)



On Thu, Jul 14, 2005 at 11:56:53AM +0200, Roberto Diaz wrote:

How do I iterate the string?

  depends what you want to do with it

  while ( myString[i] != 0) {

      i++;
  }

This is ok in case I know all characters are represented by one byte..
(this is what I understand).

  no this is *always* okay. 0 is the string terminator

  or you can use xmlGetUTF8Char() to go though each character code point
using the returned len to increment the i byte index.

But it seems that len it is also a parameter expected by the function..
actually it is an in/out parameter..  How Can I find out the size of my
characters?

  input is length in bytes of the string
  output is length in bytes of the character returned

Daniel

-- 
Daniel Veillard      | Red Hat Desktop team http://redhat.com/
veillard redhat com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]