Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Unicode word wrapping

by ph0enix (Friar)
on Dec 09, 2002 at 09:40 UTC ( [id://218485]=note: print w/replies, xml ) Need Help??


in reply to Unicode word wrapping

I don't know what can be wrong...

What about following code?

... use utf8; my $max_text_len = 40; ... sub split_text { my $intext = shift || return ''; my @result = (); my $index = 0; foreach my $word (split(' ', $intext)) { next if !length($word); if (length("$result[$index] $word") > $max_text_len) { $index++; $result[$index] = $word; } else { $result[$index] .= ($result[$index] ? ' ' : '').$word; } } return join("\n", @result); }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://218485]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2024-04-25 13:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found