From 1d4172a01f48649e67f6b85e0338c99d598229f6 Mon Sep 17 00:00:00 2001 From: Zhiger <17448542+zh1gr@users.noreply.github.com> Date: Thu, 16 Feb 2023 19:06:39 +0600 Subject: [PATCH] fix: wrong randomText when unicode preset (#8) --- captcha.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/captcha.go b/captcha.go index da857b4..b34baac 100644 --- a/captcha.go +++ b/captcha.go @@ -186,9 +186,9 @@ func drawWithOption(text string, img *image.NRGBA, options *Options) error { } func randomText(opts *Options) (text string) { - n := len(opts.CharPreset) + n := len([]rune(opts.CharPreset)) for i := 0; i < opts.TextLength; i++ { - text += string(opts.CharPreset[rand.Intn(n)]) + text += string([]rune(opts.CharPreset)[rand.Intn(n)]) } return text