MCPcopy Create free account
hub / github.com/apache/cloudberry / pg_wcswidth

Function pg_wcswidth

src/fe_utils/mbprint.c:176–198  ·  view source on GitHub ↗

* pg_wcswidth is the dumb display-width function. * It assumes that everything will appear on one line. * OTOH it is easier to use than pg_wcssize if this applies to you. */

Source from the content-addressed store, hash-verified

174 * OTOH it is easier to use than pg_wcssize if this applies to you.
175 */
176int
177pg_wcswidth(const char *pwcs, size_t len, int encoding)
178{
179 int width = 0;
180
181 while (len > 0)
182 {
183 int chlen,
184 chwidth;
185
186 chlen = PQmblen(pwcs, encoding);
187 if (len < (size_t) chlen)
188 break; /* Invalid string */
189
190 chwidth = PQdsplen(pwcs, encoding);
191 if (chwidth > 0)
192 width += chwidth;
193
194 pwcs += chlen;
195 len -= chlen;
196 }
197 return width;
198}
199
200/*
201 * pg_wcssize takes the given string in the given encoding and returns three

Callers 1

describeOneTableDetailsFunction · 0.85

Calls 2

PQmblenFunction · 0.85
PQdsplenFunction · 0.85

Tested by

no test coverage detected