mirror of
https://github.com/pragma-/pbot.git
synced 2025-05-03 13:17:33 +02:00
ValidateString: oops, this string is supposed to be UTF8
This commit is contained in:
parent
8f365d8eeb
commit
f2d3edd79b
@ -12,6 +12,7 @@ our @ISA = qw/Exporter/;
|
|||||||
our @EXPORT = qw/validate_string/;
|
our @EXPORT = qw/validate_string/;
|
||||||
|
|
||||||
use JSON;
|
use JSON;
|
||||||
|
use Encode;
|
||||||
use Unicode::Truncate;
|
use Unicode::Truncate;
|
||||||
|
|
||||||
# validate_string converts a given string to one that conforms to
|
# validate_string converts a given string to one that conforms to
|
||||||
@ -85,6 +86,7 @@ sub validate_this_string {
|
|||||||
|
|
||||||
# truncate safely
|
# truncate safely
|
||||||
if ($max_length > 0) {
|
if ($max_length > 0) {
|
||||||
|
$string = encode('UTF-8', $string);
|
||||||
$string = truncate_egc $string, $max_length;
|
$string = truncate_egc $string, $max_length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user