\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_protractor_node_modules_string_width_readme_autotoc_md23089}{}\doxysection{Install}\label{md_sfcode_node_modules_protractor_node_modules_string_width_readme_autotoc_md23089}

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

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

\begin{DoxyCode}{0}
\DoxyCodeLine{const stringWidth = require('string-\/width');}
\DoxyCodeLine{}
\DoxyCodeLine{stringWidth('a');}
\DoxyCodeLine{//=> 1}
\DoxyCodeLine{}
\DoxyCodeLine{stringWidth('古');}
\DoxyCodeLine{//=> 2}
\DoxyCodeLine{}
\DoxyCodeLine{stringWidth('\(\backslash\)u001B[1m古\(\backslash\)u001B[22m');}
\DoxyCodeLine{//=> 2 }

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

\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}

\DoxyHorRuler{0}


 {\bfseries{ \href{https://tidelift.com/subscription/pkg/npm-string-width?utm_source=npm-string-width&utm_medium=referral&utm_campaign=readme}{\texttt{ Get professional support for this package with a Tidelift subscription}} }} ~\newline
 \textsubscript{ Tidelift helps make open source sustainable for maintainers while giving companies~\newline
assurances about security, maintenance, and licensing for their dependencies. }  