Пример #1
0
func Fuzz(data []byte) int {
	s := string(data)
	si := len(s) / 4 * 3
	s0 := s[:si]
	s1 := s[si:]
	s2, r := splitRune(s)
	s3 := s[:len(s)/2]
	s4 := s[len(s)/2:]
	s5 := s[:len(s)/3]
	s6 := s[len(s)/3 : len(s)/3*2]
	s7 := s[len(s)/3*2:]

	strings.Contains(s0, s1)
	strings.ContainsAny(s0, s1)
	strings.ContainsRune(s, r)
	strings.Count(s0, s1)
	strings.EqualFold(s3, s4)
	fields := strings.Fields(s)
	strings.HasPrefix(s0, s1)
	strings.HasSuffix(s0, s1)
	strings.Index(s0, s1)
	strings.IndexAny(s0, s1)
	strings.IndexByte(s2, byte(r))
	strings.IndexRune(s2, r)
	strings.Join(fields, " ")
	strings.LastIndex(s0, s1)
	strings.LastIndexAny(s0, s1)
	strings.Repeat(s, 2)
	strings.Replace(s, s0, s1, -1)
	strings.Split(s0, s1)
	strings.SplitAfter(s0, s1)
	strings.SplitAfterN(s0, s1, 2)
	strings.SplitN(s0, s1, 2)
	strings.Title(s)
	strings.ToLower(s)
	strings.ToLowerSpecial(unicode.AzeriCase, s)
	strings.ToTitle(s)
	strings.ToTitleSpecial(unicode.AzeriCase, s)
	strings.ToUpper(s)
	strings.ToUpperSpecial(unicode.AzeriCase, s)
	strings.Trim(s0, s1)
	strings.TrimLeft(s0, s1)
	strings.TrimPrefix(s0, s1)
	strings.TrimRight(s0, s1)
	strings.TrimSpace(s)
	strings.TrimSuffix(s0, s1)
	strings.NewReplacer(s5, s6).Replace(s7)
	return 0
}
Пример #2
0
func split(line string) (r mecabResult) {
	var hiraKataCase = unicode.SpecialCase{
		unicode.CaseRange{0x3041, 0x3096, [unicode.MaxCase]rune{0, 0x30a1 - 0x3041, 0}},
		unicode.CaseRange{0x30a1, 0x30fa, [unicode.MaxCase]rune{0x3041 - 0x30a1, 0, 0x3041 - 0x30a1}},
	}

	l := strings.Split(line, "\t")
	r.Surface = l[0]

	features := strings.Split(l[1], ",")
	r.Pos = (posType)(features[0])
	r.Pos1 = features[1]
	r.Pos2 = features[2]
	r.Pos3 = features[3]
	r.ConForm = features[4]
	r.ConType = features[5]
	r.Base = features[6]
	if len(features) > 7 {
		r.Read = strings.ToUpperSpecial(hiraKataCase, features[7])
		r.Pron = strings.ToUpperSpecial(hiraKataCase, features[8])
	}

	return r
}
Пример #3
0
func (h C2Header) Execute(report gr.GoReport) {
	cols := report.Records[report.DataPos].([]string)
	y := 32.0
	x := 25.0
	if report.SumWork["g2item"] == 0.0 {
		numConv := unicode.SpecialCase{
			// 半角の 0 から 9 に対する変換ルール
			unicode.CaseRange{
				0x0030, // Lo: 半角の 0
				0x0039, // Hi: 半角の 9
				[unicode.MaxCase]rune{
					0xff10 - 0x0030, // UpperCase で全角に変換
					0,               // LowerCase では変換しない
					0xff10 - 0x0030, // TitleCase で全角に変換
				},
			},
		}
		report.Font("IPAexゴシック", 10, "")

		now := strings.ToUpperSpecial(
			numConv, time.Now().Format(C2DateFormat))
		report.CellRight(182, 12, 0, now)
		report.CellRight(182, 19, 0, "請求書番号:"+cols[2])
		report.Font("IPAexゴシック", 16, "")
		report.Cell(92, 30, "請求書")
		report.Font("IPAexゴシック", 11, "")
		x = 118.0
		report.Cell(x, 46, "サンプル商事株式会社")
		report.Cell(x, 51, "山田太郎")
		report.Font("IPAexゴシック", 9, "")
		report.Cell(x, 58, "〒181-0001")
		report.Cell(x, 62, "東京都三鷹市井の頭5-12-12")
		report.Cell(x, 72, "TEL:0422-22-2222")
		report.Cell(x, 76, "FAX:0422-22-2223")
		report.Cell(x, 80, "*****@*****.**")
		cols = cols
		x = 25
		report.Font("IPAexゴシック", 12, "")
		company := cols[1] + " 御中"
		// 注意 Pdf.SetFontは呼び出し順が違う
		report.Converter.Pdf.SetFont("IPAexゴシック", "", 12)
		w, _ := report.Converter.Pdf.MeasureTextWidth(company)
		report.Cell(x, 46, company)
		report.LineType("straight", 0.3)
		report.GrayStroke(0.5)
		report.LineH(x, 50, x+w/report.ConvPt)
		report.Font("IPAexゴシック", 9, "")
		report.Cell(x, 58, "下記のとおりご請求申し上げます。")
		report.Font("IPAexゴシック", 12, "")
		report.Cell(x, 70, "ご請求金額")
		report.CellRight(x+72, 70, 0, "¥"+gr.AddComma(cols[10])+"-")
		report.LineH(x, 74, x+72)
		report.GrayStroke(0)
		y = 85
	}
	report.LineType("straight", 5)
	report.GrayStroke(0.85)
	report.LineH(x, y, x+160)
	report.LineType("straight", 0.3)
	report.GrayStroke(0)
	report.Rect(x, y, x+160, y+5)
	report.LineV(x+23, y, y+5)
	report.LineV(x+41, y, y+5)
	report.LineV(x+61, y, y+5)
	report.LineV(x+99, y, y+5)
	report.LineV(x+116, y, y+5)
	report.LineV(x+135, y, y+5)
	report.Font("IPAexゴシック", 10, "")
	yadd := 1.5
	report.Cell(x+5, y+yadd, "年月日")
	report.Cell(x+28, y+yadd, "伝票")
	report.Cell(x+47, y+yadd, "品番")
	report.Cell(x+76, y+yadd, "品名")
	report.Cell(x+104, y+yadd, "数量")
	report.Cell(x+122, y+yadd, "単価")
	report.Cell(x+144, y+yadd, "金額")
	report.SumWork["g1item"] = 0.0
	report.SumWork["g2item"] = 1.0
}
Пример #4
0
func toUpper(s string) string {
	return strings.ToUpperSpecial(unicode.TurkishCase, s)
}
Пример #5
0
//ToUpperSpecial returns a copy of thr string s with all Unicode letters mapped to their upper case
// giving priority to the special casing rules
func ToUpperSpecial(_case unicode.SpecialCase, s string) string {
	fmt.Println(strings.ToUpperSpecial(unicode.AzeriCase, "şğüöıi")) // ŞĞÜÖIİ
	return strings.ToUpperSpecial(_case, s)
}
Пример #6
0
/*
_case 规则说明,以下列语句为例:
unicode.CaseRange{'A', 'Z', [unicode.MaxCase]rune{3, -3, 0}}
·其中 'A', 'Z' 表示此规则只影响 'A' 到 'Z' 之间的字符。
·其中 [unicode.MaxCase]rune 数组表示:
当使用 ToUpperSpecial 转换时,将字符的 Unicode 编码与第一个元素值(3)相加
当使用 ToLowerSpecial 转换时,将字符的 Unicode 编码与第二个元素值(-3)相加
当使用 ToTitleSpecial 转换时,将字符的 Unicode 编码与第三个元素值(0)相加

*/
func main() {
	var SC unicode.SpecialCase
	fmt.Println(strings.ToUpperSpecial(SC, "Gopher"))
	//GOPHER
}
Пример #7
0
func (ck ckey) decipher(ct string) string {
	return strings.ToUpperSpecial(ck.dec, ct)
}
Пример #8
0
func (ck ckey) encipher(pt string) string {
	return strings.ToUpperSpecial(ck.enc, pt)
}