From f0870a4d2ec589bf5de268a54d51c1da197ed882 Mon Sep 17 00:00:00 2001 From: Ryo Nihei Date: Sun, 28 Nov 2021 17:50:38 +0900 Subject: Remove default value's code points of General_Category --- ucd/api.go | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'ucd/api.go') diff --git a/ucd/api.go b/ucd/api.go index 1ffc84f..f0bc1d2 100644 --- a/ucd/api.go +++ b/ucd/api.go @@ -75,6 +75,25 @@ func FindCodePointRanges(propName, propVal string) ([]*CodePointRange, bool, err if !ok { return nil, false, fmt.Errorf("unsupported character property value: %v", propVal) } + if val == generalCategoryValueAbbs[normalizeSymbolicValue(generalCategoryDefaultValue)] { + var allCPs []*CodePointRange + if generalCategoryDefaultRange.From > codePointMin { + allCPs = append(allCPs, &CodePointRange{ + From: codePointMin, + To: generalCategoryDefaultRange.From - 1, + }) + } + if generalCategoryDefaultRange.To < codePointMax { + allCPs = append(allCPs, &CodePointRange{ + From: generalCategoryDefaultRange.To + 1, + To: codePointMax, + }) + } + for _, cp := range generalCategoryCodePoints { + allCPs = append(allCPs, cp...) + } + return allCPs, true, nil + } vals, ok := compositGeneralCategories[val] if !ok { vals = []string{val} @@ -98,13 +117,13 @@ func FindCodePointRanges(propName, propVal string) ([]*CodePointRange, bool, err if scriptDefaultRange.From > codePointMin { allCPs = append(allCPs, &CodePointRange{ From: codePointMin, - To: scriptDefaultRange.From - 1, + To: scriptDefaultRange.From - 1, }) } if scriptDefaultRange.To < codePointMax { allCPs = append(allCPs, &CodePointRange{ From: scriptDefaultRange.To + 1, - To: codePointMax, + To: codePointMax, }) } for _, cp := range scriptCodepoints { -- cgit v1.2.3