Multibyte-character-string traversal

Because a multibyte-character string might contain multibyte characters of different sizes, you cannot automatically traverse the string with any built-in scaling. Instead, use the following functions in to traverse a multibyte string:
  • The ifx_gl_mblen() function determines the number of bytes in a multibyte character.
  • The ifx_gl_mbsnext() function returns a pointer to the next multibyte character in the multibyte string.
  • The ifx_gl_mbsprev() function returns a pointer to the previous multibyte character in the multibyte string.
These functions support string traversal in the following directions:
  • Forward
    gl_mchar_t buf[], *p;
    for ( p = buf; *p != ‘\0' ;
           p = ifx_gl_mbsnext(p, IFX_GL_NO_LIMIT))
       process_mchar(p);
  • Backward
    gl_mchar_t buf[], *p;
    p = ifx_gl_mbsprev(buf, buf + strlen(buf));
    if ( p != NULL )
       for ( ; p >= buf; p = ifx_gl_mbsprev(buf, p) )
          process_mchar(p);