Repository navigation
fix(package): [strutil] handle non-ASCII letters in case conversion - #413
Merged
Merged
Conversation
duke-git
approved these changes
Nov 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CamelCase,UpperCamelCase,KebabCase,UpperKebabCase,SnakeCaseandUpperSnakeCaseonly treated 'a'-'z' and 'A'-'Z' as cased letters, so other cased letters were not split or converted correctly. On the base commit:SnakeCase("Привет Мир")returns"Привет Мир"(not lowercased, not split).KebabCaseandUpperSnakeCasegive the same unchanged string.SnakeCase("Köln Straße")returns"k_ö_ln_stra_ß_e"andCamelCase("Köln Straße")returns"kÖLnStraßE".SnakeCase("élanVital")returns"é_lan_vital".The helpers
isLower,isUpper,toLowerandtoUpperinstrutil/string_internal.gonow useunicode.IsLower,unicode.IsUpper,unicode.ToLowerandunicode.ToUpper. Uncased letters such as CJK stay in the same group as before, and the ASCII results are unchanged.After the change:
SnakeCase("Привет Мир")is"привет_мир",UpperKebabCasegives"ПРИВЕТ-МИР",CamelCase("Köln Straße")is"kölnStraße".Output changes for non-ASCII input, which is the point of this fix. Limits:
ßis not expanded toSSwhen upper-cased (Go's simple case mapping keepsß).Džare now classified byunicode.IsLower/IsUpper, so their splitting changes.Tests: I added two rows (
Привет Мир,Köln Straße) to each of the six case-function tests. On go1.26.6 (Linux amd64),go test ./strutil,go vet ./strutilandgofmt -l strutilare clean, and the new rows fail on the base commit.go test ./...has two failures,TestTelnetConnectedandExampleIsTelnetConnectedinnetutil. They fail identically on the base commit in my environment, which has no external network access, and I did not investigate the cause.strutilalso passes underGOARCH=386.