// HC017: Non-ASCII Quotes detection // Detects fancy quotes like " " ' ' and reports their locations. static box RuleNonAsciiQuotesBox { apply(text, path, out) { if text == null { return 0 } local lines = me._split_lines(text) local i = 0 while i < lines.size() { local ln = lines.get(i) if me._has_fancy_quote(ln) == 1 { out.push("[HC017] non-ASCII quotes detected: " + path + ":" + me._itoa(i+1)) } i = i + 1 } return 0 } _has_fancy_quote(s) { if s == null { return 0 } // Check for common fancy quotes: U+201C/U+201D/U+2018/U+2019 if s.indexOf(""") >= 0 { return 1 } if s.indexOf(""") >= 0 { return 1 } if s.indexOf("'") >= 0 { return 1 } if s.indexOf("'") >= 0 { return 1 } return 0 } _split_lines(s) { local arr=new ArrayBox(); if s==null {return arr} local n=s.length(); local last=0; local i=0; loop(i0 { local d=v%10; tmp=digits.substring(d,d+1)+tmp; v=v/10 } out=tmp; return out } } static box RuleNonAsciiQuotesMain { method main(args) { return 0 } }