Text-VisualWidth

 view release on metacpan or  search on metacpan

VisualWidth.xs  view on Meta::CPAN

      continue_flg = 0;
    }
  }
  return newSVpvn((const char *)default_pos , byte_length);
}

int count_single_char_utf8( const unsigned char** pos, int* byte ){
  *byte = 0;
  if( **pos == 0 ) return 0;
  if( **pos == 0xef && *((*pos)+1) == 0xbb && *((*pos)+2) == 0xbf ){
    // BOM
    (*pos)+= 3;
    (*byte)+= 3;
//    printf("BOM\n");
    return 0;
  } else if( ( **pos & 0xe0 ) == 0xc0 && ( ( *((*pos)+1) & 0xc0 ) == 0x80 ) ){
    (*pos)+= 2;
    (*byte)+= 2;
//    printf("2byte\n");
    return 1;
  } else if( ( **pos & 0xf0 ) == 0xe0 && ( ( *((*pos)+1) & 0xc0 ) == 0x80 ) && ( ( *((*pos)+2) & 0xc0 ) == 0x80 ) ){
    if( **pos == 0xef && ( ( *((*pos)+1) == 0xbd && *((*pos)+2) >= 0xa1 && *((*pos)+2) <= 0xbf )
                      || ( *((*pos)+1) == 0xbe && *((*pos)+2) >= 0x80 && *((*pos)+2) <= 0x9f ) ) ){
      (*pos)+= 3;



( run in 0.829 second using v1.01-cache-2.11-cpan-131fc08a04b )