ValidateString: oops, this string is supposed to be UTF8

This commit is contained in:
Pragmatic Software 2021-06-21 11:33:53 -07:00
parent 8f365d8eeb
commit f2d3edd79b
1 changed files with 2 additions and 0 deletions

View File

@ -12,6 +12,7 @@ our @ISA = qw/Exporter/;
our @EXPORT = qw/validate_string/;
use JSON;
use Encode;
use Unicode::Truncate;
# validate_string converts a given string to one that conforms to
@ -85,6 +86,7 @@ sub validate_this_string {
# truncate safely
if ($max_length > 0) {
$string = encode('UTF-8', $string);
$string = truncate_egc $string, $max_length;
}