DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR New]

Link: http://www.fltk.org/str.php?L2348
Version: 1.3-current





Link: http://www.fltk.org/str.php?L2348
Version: 1.3-current
#include <FL/Fl.H>
#include <FL/fl_utf8.h>

char example1[] = {'a','b','c','\xc2','\x99','\x80','x','y','z',     '\0'};
char example2[] = {'a','b','c','\x80','\x80','\x80','\x80','y','z',  '\0'};

void output(const char* s, const char* p) {
  for (int i = 0; i <= strlen(s); i++) {
    char c = s[i];
    if (p == s+i) printf("|");
    if (c != '\0') printf("\\x%02hhx,", c);
  }
  printf("\n");
}
                        
int main(int argc, char* argv[]) {
  const char* start = example1;
  const char* end   = example1 + strlen(example1);
  const char* p = 0;

  printf("Test 1:  fl_utf8fwd() loop : aaa12Xaaa\n");
  p = start;
  while (p < end) {
    output(start, p);
    p++;
    p = fl_utf8fwd(p, start, end);
  }

  printf("Test 2: fl_utf8back() loop : aaa12Xaaa\n");
  p = end;
  while (p > start) {
    output(start, p);
    p--;
    p = fl_utf8back(p, start, end);
  }

  start = example2;
  end   = example2 + strlen(example2);

  printf("Test 3:  fl_utf8fwd() loop : aaaXXXXaa\n");
  p = start;
  while (p < end) {
    output(start, p);
    p++;
    p = fl_utf8fwd(p, start, end);
  }

  printf("Test 2: fl_utf8back() loop : aaaXXXXaa\n");
  p = end;
  while (p > start) {
    output(start, p);
    p--;
    p = fl_utf8back(p, start, end);
  }

  return 0;
}

_______________________________________________
fltk-bugs mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-bugs

Reply via email to