\begin{quote}
Get the visual width of a string -\/ the number of columns required to display it \end{quote}
Some Unicode characters are \href{https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms}{\texttt{ fullwidth}} and use double the normal width. \href{https://en.wikipedia.org/wiki/ANSI_escape_code}{\texttt{ ANSI escape codes}} are stripped and doesn\textquotesingle{}t affect the width.

Useful to be able to measure the actual width of command-\/line output.\hypertarget{md_sfcode_node_modules_string_width_readme_autotoc_md29103}{}\doxysection{Install}\label{md_sfcode_node_modules_string_width_readme_autotoc_md29103}

\begin{DoxyCode}{0}
\DoxyCodeLine{\$ npm install string-\/width }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_string_width_readme_autotoc_md29104}{}\doxysection{Usage}\label{md_sfcode_node_modules_string_width_readme_autotoc_md29104}

\begin{DoxyCode}{0}
\DoxyCodeLine{const stringWidth = require('string-\/width');}
\DoxyCodeLine{}
\DoxyCodeLine{stringWidth('古');}
\DoxyCodeLine{//=> 2}
\DoxyCodeLine{}
\DoxyCodeLine{stringWidth('\(\backslash\)u001b[1m古\(\backslash\)u001b[22m');}
\DoxyCodeLine{//=> 2}
\DoxyCodeLine{}
\DoxyCodeLine{stringWidth('a');}
\DoxyCodeLine{//=> 1}
\DoxyCodeLine{}
\DoxyCodeLine{stringWidth('\(\backslash\)u001B]8;;https://github.com\(\backslash\)u0007Click\(\backslash\)u001B]8;;\(\backslash\)u0007');}
\DoxyCodeLine{// => 5 }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_string_width_readme_autotoc_md29105}{}\doxysection{Related}\label{md_sfcode_node_modules_string_width_readme_autotoc_md29105}

\begin{DoxyItemize}
\item \href{https://github.com/sindresorhus/string-width-cli}{\texttt{ string-\/width-\/cli}} -\/ CLI for this module
\item \href{https://github.com/sindresorhus/string-length}{\texttt{ string-\/length}} -\/ Get the real length of a string
\item \href{https://github.com/sindresorhus/widest-line}{\texttt{ widest-\/line}} -\/ Get the visual width of the widest line in a string
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_string_width_readme_autotoc_md29106}{}\doxysection{License}\label{md_sfcode_node_modules_string_width_readme_autotoc_md29106}
MIT © \href{https://sindresorhus.com}{\texttt{ Sindre Sorhus}} 