Guest User

Untitled

a guest
Jul 19th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. *{AnyEvent::IRC::Util::split_unicode_string} = sub {
  2. my ($enc, $str, $maxlen) = @_;
  3.  
  4. return $str unless length (encode ($enc, $str)) > $maxlen;
  5.  
  6. my $cur_out = '';
  7. my $word = '';
  8. my @lines;
  9.  
  10. while (length ($str) > 0) {
  11. $word .= substr $str, 0, 1, '';
  12.  
  13. if ($word =~ /\w\W$/ || length ($str) == 0) {
  14.  
  15. if (length (encode ($enc, $cur_out.$word)) > $maxlen) {
  16. push @lines, $cur_out;
  17. $cur_out = '';
  18. }
  19.  
  20. $cur_out .= $word;
  21. $word = '';
  22. }
  23. }
  24.  
  25. push @lines, $cur_out if length ($cur_out);
  26. };
Add Comment
Please, Sign In to add comment