Skip to content

Instantly share code, notes, and snippets.

@roxlu
Created January 23, 2015 21:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roxlu/7d73f8928e7e8489ae65 to your computer and use it in GitHub Desktop.
Save roxlu/7d73f8928e7e8489ae65 to your computer and use it in GitHub Desktop.
#include <unicode/uchriter.h>
#include <unicode/schriter.h>
#include <unicode/ustring.h>
#include <stdio.h>
#include <unicode/ustdio.h>
#include <unicode/brkiter.h>
#include <stdlib.h>
using namespace poly;
int main() {
UnicodeString ts("綧緁緅 襏襆贂 峷敊浭");
const UChar* ts_ptr = ts.getTerminatedBuffer();
UBreakIterator* bi = NULL;
int32_t p = 0;
UErrorCode err = U_ZERO_ERROR;
bi = ubrk_open(UBRK_CHARACTER, 0, ts_ptr, u_strlen(ts_ptr), &err);
if (U_FAILURE(err)) {
printf("Error: failed to create a break iterator.");
return -1;
}
p = ubrk_first(bi);
while (p != UBRK_DONE) {
printf("Boundary at position: %d\n", p);
p = ubrk_next(bi);
}
ubrk_close(bi);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment