Returns console width of unicode values >>> getConsoleLength("abc") 3 >>> getConsoleLength(u"\\u957f\\u6c5f") 4
(value)
| 451 | return retVal |
| 452 | |
| 453 | def getConsoleLength(value): |
| 454 | """ |
| 455 | Returns console width of unicode values |
| 456 | |
| 457 | >>> getConsoleLength("abc") |
| 458 | 3 |
| 459 | >>> getConsoleLength(u"\\u957f\\u6c5f") |
| 460 | 4 |
| 461 | """ |
| 462 | |
| 463 | if isinstance(value, six.text_type): |
| 464 | retVal = len(value) + sum(ord(_) >= 0x3000 for _ in value) |
| 465 | else: |
| 466 | retVal = len(value) |
| 467 | |
| 468 | return retVal |
no outgoing calls
no test coverage detected
searching dependent graphs…