summaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c
index 4984794..c98a98a 100644
--- a/src/util.c
+++ b/src/util.c
@@ -660,3 +660,25 @@ int zero_space(unsigned char *buf, __u32 offset){
i++;
return (i == end ) ? 1 : 0 ;
}
+
+int is_unicode( unsigned char* buf){
+ int ret = 0;
+ unsigned char *p = buf;
+ unsigned char *p1 = buf +1;
+ if ((*p > 0xc1) && (*p < 0xf5) && (*p1 > 0x7f) && (*p1 < 0xc0)){
+ if (!(*p & 0x20))
+ ret = 2;
+ else{
+ p1++;
+ if ((!(*p & 0x10)) && (*p1 > 0x7f) && (*p1 < 0xc0))
+ ret = 3 ;
+ else{
+ p1++;
+ if ((!(*p & 0x08)) && (*p1 > 0x7f) && (*p1 < 0xc0))
+ ret = 4 ;
+ }
+ }
+ }
+ return ret;
+}
+