-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbidiExample.cpp
More file actions
70 lines (41 loc) · 1.31 KB
/
Copy pathbidiExample.cpp
File metadata and controls
70 lines (41 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include "unicode/utypes.h"
#include "unicode/uchar.h"
#include "unicode/localpointer.h"
#include "unicode/ubidi.h"
#include <unicode/unistr.h>
#include<string>
#include<iostream>
using namespace std;
using namespace icu;
using icu::UnicodeString;
int main(int argc,char* argv[])
{
UnicodeString us(argv[1]);
UBiDi * bidi=ubidi_open ();
UErrorCode errorCode = U_ZERO_ERROR;
UBiDiLevel paraLevel= UBIDI_DEFAULT_LTR;
ubidi_setPara(bidi,us.getBuffer(),us.length(),paraLevel,nullptr,&errorCode);
if (U_SUCCESS(errorCode))
{
UnicodeString Ustring(ubidi_getText(bidi));
string Ustr;
Ustring.toUTF8String(Ustr);
int32_t count=ubidi_countRuns(bidi,&errorCode);
int32_t logicalStart, length;
for(int32_t i=0; i<count; i++) {
UBiDiDirection dir=ubidi_getVisualRun(bidi, i, &logicalStart, &length);
string dirstr = "UBIDI_LTR";
if (dir == UBIDI_RTL)
dirstr = "UBIDI_RTL";
string str55;
UnicodeString temp=Ustring.tempSubString(logicalStart,length);
temp.toUTF8String(str55);
cout << "VisualRun \t" << dirstr << "\t"<< logicalStart<<'\t'<<length<<'\t'<<str55<<endl;
}
}
else
{
cout << "Failed" << endl;
}
return 0;
}