Can I use the browser's word-wrapping from JavaScript?

Posted by Max on Stack Overflow See other posts from Stack Overflow or by Max
Published on 2010-06-16T02:29:53Z Indexed on 2010/06/16 2:32 UTC
Read the original article Hit count: 217

Filed under:
|
|

I have some text in a div. It can be any Unicode text under the sun, including Chinese, Japanese, and Korean. Now, I need to take this text and word-wrap it in JavaScript in some efficient but correct manner. (Because I need to make each line start with ">" in a textarea.)

Browsers have an implementation of the Unicode Word Wrap algorithm, as is evidenced by word-wrapping Unicode text in a with CSS. (At least, Firefox has such an algorithm, and I suspect other browsers do as well.) What I need is some way for JavaScript to use the same word-wrapping algorithm, so that I can properly wrap and then "quote" Unicode text.

Is there any way for JavaScript to use the browser's word-wrapping algorithm, or to know where text has been line-broken in a div or any other element?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about browser