Changeset 681 for proto/parabix2


Ignore:
Timestamp:
Oct 29, 2010, 2:33:37 PM (9 years ago)
Author:
ksherdy
Message:

Update validate_utf8.

Location:
proto/parabix2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • proto/parabix2/parabix2.py

    r593 r681  
     1# -*- coding: utf-8 -*-
    12#
    23# parabix2.py
  • proto/parabix2/u8u16.py

    r680 r681  
    2525
    2626def validate_utf8(u8):
     27        u8.scope22 = bitutil.Advance(u8.prefix2)
     28        u8.scope32 = bitutil.Advance(u8.prefix3)
     29        u8.scope33 = bitutil.Advance(u8.scope32)
     30        u8.scope42 = bitutil.Advance(u8.prefix4)
     31        u8.scope43 = bitutil.Advance(u8.scope42)
     32        u8.scope44 = bitutil.Advance(u8.scope43)
    2733        u8lastscope = u8.scope22 | u8.scope33 | u8.scope44
    2834        u8anyscope = u8lastscope | u8.scope32 | u8.scope42 | u8.scope43
    29        
     35
     36             
    3037        # C0-C1 and F5-FF are illegal
    3138        error_mask = u8.badprefix
    32        
    33         error_mask |= u8.xE0_scope & u8.x80_x9F
    34         error_mask |= u8.xED_scope & u8.xA0_xBF
    35         error_mask |= u8.xF0_scope & u8.x80_x8F
    36         error_mask |= u8.xF4_scope & u8.x90_xBF
    37        
     39             
     40        error_mask |= bitutil.Advance(u8.xE0) & u8.x80_x9F
     41        error_mask |= bitutil.Advance(u8.xED) & u8.xA0_xBF
     42        error_mask |= bitutil.Advance(u8.xF0) & u8.x80_x8F
     43        error_mask |= bitutil.Advance(u8.xF4) & u8.x90_xBF
     44             
    3845        error_mask |= u8anyscope ^ u8.suffix
    39         u8.error = error_mask
     46        u8.error = error_mask   
    4047        return u8
    4148
Note: See TracChangeset for help on using the changeset viewer.