String length: Difference between revisions

Content added Content deleted
(Added solution for Action!)
m (Emacs Lisp: Add comments)
Line 1,260: Line 1,260:
===Character Length===
===Character Length===
<lang lisp>(length "hello")
<lang lisp>(length "hello")
=> 5</lang>
;; => 5</lang>
===Byte Length===
===Byte Length===
<lang lisp>(string-bytes "\u1D518\u1D52B\u1D526")
<lang lisp>(string-bytes "\u1D518\u1D52B\u1D526")
=> 12</lang>
;; => 12</lang>


<code>string-bytes</code> is the length of Emacs' internal representation. In Emacs 23 up this is utf-8. In earlier versions it was "emacs-mule".
<code>string-bytes</code> is the length of Emacs' internal representation. In Emacs 23 up this is utf-8. In earlier versions it was "emacs-mule".
Line 1,276: Line 1,276:
(string-bytes str)
(string-bytes str)
(string-width str)))
(string-width str)))
=> (6 18 4) ;; in emacs 23 up</lang>
;; => (6 18 4) ;; in emacs 23 up</lang>


=={{header|Erlang}}==
=={{header|Erlang}}==