Github user viirya commented on a diff in the pull request: https://github.com/apache/spark/pull/16086#discussion_r90449169 --- Diff: sql/core/src/main/scala/org/apache/spark/sql/Dataset.scala --- @@ -236,6 +238,37 @@ class Dataset[T] private[sql]( } } + var EAST_ASIAN_LANGS = Seq("ja", "vi", "kr", "zh") + + private def unicodeWidth(str: String): Int = { + val locale = Locale.getDefault() + if (locale == null) { + throw new NullPointerException("locale is null") + } + val ambiguousLen = if (EAST_ASIAN_LANGS.contains(locale.getLanguage())) 2 else 1 + var len = 0 + for (i <- 0 until str.length) { + val codePoint = str.codePointAt(i) + val value = UCharacter.getIntPropertyValue(codePoint, UProperty.EAST_ASIAN_WIDTH); + len = len + (value match { + case UCharacter.EastAsianWidth.NARROW | UCharacter.EastAsianWidth.NEUTRAL | + UCharacter.EastAsianWidth.HALFWIDTH => 1 --- End diff -- ident looks weird.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org