NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
Go modules, #1424 by repository stars
Latest stable
v1.6.4
Last release 2 days ago
20 Nov 2026
Release timing varies
gaps range from 2 weeks to 2.3 years
Most releases are documented
notes for 11 of 15 stable releases
Nothing withdrawn
no release was ever pulled
12 years old
52 releases · first in 2015
Drag across the ruler to compare, or tap a release to open it.
Nothing published for this version
This release fixes invalid UTF-8 handling in ExpandTabs, Squeeze and the justification helpers, and makes FirstRuneToUpper / FirstRuneToLower honor al
This release fixes invalid UTF-8 handling in ExpandTabs, Squeeze and the justification helpers, and makes FirstRuneToUpper / FirstRuneToLower honor all Unicode case mappings.
Most fixes preserve bytes which were not supposed to be changed. As a result, invalid UTF-8 bytes are no longer rewritten as U+FFFD in these functions; valid UTF-8 output is unchanged.
ExpandTabs: invalid bytes after the first tabExpandTabs copied the input prefix before the first tab, but every later rune was written back with WriteRune. Invalid bytes decode to utf8.RuneError and were rewritten as U+FFFD, so the same byte was preserved before a tab and corrupted after it.
ExpandTabs("\t\xffx", 4) returned " \uFFFDx" instead of " \xffx".ExpandTabs("\xff\t\xfe", 4) returned "\xff \uFFFD" instead of "\xff \xfe".Non-tab bytes are now copied unchanged.
Squeeze: retained bytes and duplicate detectionTwo separate issues affected invalid input:
WriteRune, rewriting invalid bytes as U+FFFD: Squeeze("aa\xffb", "a") returned "a\uFFFDb" instead of "a\xffb", and even a non-matching pattern such as "z" changed the bytes (#73).RuneError, so distinct invalid bytes, and an invalid byte next to a valid U+FFFD, were treated as repeated runes and collapsed: Squeeze("\xff\xfe", "") returned "\xff" and Squeeze("\xff\uFFFD", "") returned "\xff" (#76).Retained bytes are now copied unchanged, and adjacent runes are compared by their original bytes. Identical bytes still squeeze normally when the rune is eligible for squeezing, while distinct sequences are kept.
LeftJustify, RightJustify, Center: truncated pad stringsWhen the pad string was cut in the middle of its runes, writePadString decoded each pad rune and wrote it back with WriteRune. Invalid bytes in that partial pad became U+FFFD, although complete pad repetitions were already copied unchanged.
LeftJustify("a", 3, "x\xffy") returned "ax\uFFFD" instead of "ax\xff".RightJustify("a", 2, "\xffx") returned "\uFFFDa" instead of "\xffa".Center("a", 4, "x\xffy") returned "xax\uFFFD" instead of "xax\xff".Partial pad bytes are now copied unchanged (#75).
FirstRuneToUpper / FirstRuneToLower: Unicode case mappings outside Ll/LuThe functions only changed the first rune when unicode.IsLower / unicode.IsUpper was true. Characters with case mappings outside those categories were skipped, including titlecase digraphs, Roman numerals and circled letters.
FirstRuneToUpper("Džuro") returned "Džuro" instead of "DŽuro".FirstRuneToLower("Džuro") returned "Džuro" instead of "džuro".FirstRuneToUpper("ⅳ chapter") returned "ⅳ chapter" instead of "Ⅳ chapter".FirstRuneToUpper("ⓐ label") returned "ⓐ label" instead of "Ⓐ label".The functions now apply unicode.ToUpper / unicode.ToLower and return the original string when the first rune has no mapping. Suffixes, uncased runes and invalid UTF-8 are handled as before (#72).
FirstRuneToUpper and FirstRuneToLower now change every rune with a standard Unicode simple case mapping, not only runes in Ll/Lu. This includes titlecase, letterlike and circled characters.ExpandTabs, Squeeze, LeftJustify, RightJustify and Center now preserve invalid UTF-8 bytes instead of rewriting them as U+FFFD in the affected paths. The output is byte-preserving, but remains invalid UTF-8 if the input is invalid. Valid UTF-8 results are unchanged.Squeeze no longer treats different invalid byte sequences as repeated runes. Repeated identical bytes are still squeezed under the same pattern rules.go test ./..., go test -race ./..., go vet ./..., gofmt and git diff --check pass. Statement coverage remains at 99.9%.Thank you to the contributors of this release:
Full Changelog: https://github.com/huandu/xstrings/compare/v1.6.2...v1.6.3
Your coding agent can read these notes before it upgrades. Set up the MCP server →
This release documents everything since v1.6.0, including the two changes which were parked on the v1.6.1 tag. That tag never got a release note of it
This release documents everything since v1.6.0, including the two changes which were parked on the v1.6.1 tag. That tag never got a release note of its own, so its changes are listed here as well and the changelog link at the bottom compares against v1.6.0.
Both Translate bugs silently returned a wrong string instead of reporting an error, so please read the Behaviour changes section if you pass patterns which contain a literal replacement character.
Translate / Delete / Count: a literal U+FFFD in a patternThe internal marker for "no rune" was utf8.RuneError, which is the very same value as the rune U+FFFD. A literal replacement character in a from or to pattern was therefore mistaken for the end of the pattern: the rune was dropped from the pattern and every pattern rune behind it was mismapped.
Translate("\uFFFDa", "\uFFFDa", "xy") returned "\uFFFDx" instead of "xy".Delete("\uFFFDa\uFFFDb", "\uFFFDa") returned "\uFFFD\uFFFDb" instead of "b", and Count("\uFFFDa\uFFFDb", "\uFFFDa") returned 1 instead of 3.Translate("abc", "abc", "x\uFFFD") returned "xxx" instead of "x\uFFFD\uFFFD".The internal marker is noRune = -1 now, a value which decoding a string can never produce, so U+FFFD is an ordinary rune in a pattern. The historical fallback for a pattern which parses to no rune at all ("-", "---", "\\", and the same shapes behind a range such as "0-9-") is kept, and is pinned by a test now.
Translate: the last rune of a from range was dropped when to contains literalsWhen a from range was mapped onto the literal runes of a to pattern, the last rune of the range never got a mapping: it was left unchanged in the result, and as soon as more source runes followed, their replacement runes shifted.
Translate("ab", "a-b", "xy") returned "xb" instead of "xy".Translate("abc", "a-c", "xyz") returned "xyc" instead of "xyz".Translate("abc", "a-bc", "xyz") returned "xby" instead of "xyz", i.e. 'c' was mapped to the rune 'b' should have used.Translator.TranslateRune was affected too: NewTranslator("a-b", "xy").TranslateRune('b') returned ('b', false) although 'b' is part of the pattern. It returns ('y', true) now.
ToCamelCase: a single uppercase rune behind a separator was lowercasedToCamelCase lowercased the last uppercase initial of an input, so it disagreed with the lowercase spelling of the same word:
ToCamelCase("option_A") returned "optiona" instead of "optionA"; the same applied to "option-A" and "option A".ToCamelCase("HTTP_X") returned "httpx" instead of "httpX", and ToCamelCase("é_Ö") returned "éö" instead of "éÖ".The final lowercasing step was redundant — the loop already normalizes the uppercase runes inside each word — so it was removed. ToPascalCase is not affected, and neither is input which starts with an uppercase word: ToCamelCase("URL_Parser") is still "urlParser".
Scrub: documentation onlyScrub replaces invalid UTF-8 bytes and valid U+FFFD runes with repl, and a consecutive run of them is replaced only once. The doc comment now says so and has samples: Scrub("a\uFFFDb", "?") => "a?b". Runtime behaviour is unchanged.
ToCamelCase keeps a single uppercase rune behind a separator: "option_A" → "optionA" (it was "optiona"), "HTTP_X" → "httpX" (it was "httpx").U+FFFD behaves differently now, because the rune is part of the pattern instead of being removed from it. The results listed above are the only ones which change.Delete, Count and Squeeze are not affected by the range fix, and ^-reverted patterns are not affected by either of the two Translate fixes.U+0000 as a replacement rune, and an escaped - in the to pattern.Delete, Count and TranslateRune paths.ToCamelCase and six new ToPascalCase cases for the camel case fix, covering underscore, hyphen and space separators, repeated separators, an uppercase prefix and non-ASCII runes.Translate fixes were cross checked with a differential test against an independent implementation of the documented pattern semantics; no mismatch was found in tens of thousands of random from/to pattern pairs. The camel case change was compared against the previous implementation over 22,621 short strings, and only the intended results differ.Thank you for the four pull requests in this release:
Scrub handling of U+FFFD by @x0LazarusFull Changelog: https://github.com/huandu/xstrings/compare/v1.6.0...v1.6.2
Nothing published for this version
Bug fixes for Scrub, Slice, Successor, ToCamelCase and Translate, plus a much bigger test suite.
Bug fixes for Scrub, Slice, Successor, ToCamelCase and Translate, plus a much bigger test suite.
ScrubScrub appended the already written prefix a second time and kept the invalid bytes as they were: Scrub("abc\xFF", "*") returned "abcabc\xFF" instead of "abc*", and Scrub("ab\xFFcd\xFE", "*") returned "ab*cdcd\xFE" instead of "ab*cd*" (#60, thanks @vitalivo).SliceSlice with a negative end (i.e. "slice to the end of the string") did not validate start against the rune count, so an out-of-range start returned an empty string instead of panicking: Slice("abc", 4, -1), Slice("中文", 3, -1) and Slice("", 1, -1) all returned "". They now panic with "out of range", as the document promises (#61, thanks @vitalivo).Successor'9' was inserted as '0' instead of '1', so Successor("9") returned "00" instead of "10" (and "99" → "000", "9z" → "00a") (#62).Successor("中z") returned "\xe4aa" instead of "中aa" (#63).String#succ: Successor("8a_9") returned "8b_0" instead of "8a_10", Successor("1*z") returned "2*a" instead of "1*aa" (#67). A differential test against Ruby over 20000 random ASCII strings now reports zero mismatches.ToCamelCase / ToPascalCaseToCamelCase("_") returned "__", ToCamelCase(" ") returned " ", ToCamelCase("-_-") returned "-_--" (#64).Translate / Deleteutf8.RuneError was dropped. A valid U+FFFD rune which did not match the pattern disappeared, and invalid bytes were removed as well: Translate("a\uFFFDb", "a", "x") returned "xb" instead of "x\uFFFDb", Delete("a\uFFFDb", "a") returned "b" instead of "\uFFFDb" (#65).U+0000 was silently ignored, because 0 was used as the "no mapping" marker: Translate("hello", "h", "\x00") returned "hello" instead of "\x00ello" (#66).Two results change on purpose. Please check them if you depend on the exact output:
Translate/Delete now keep every rune which does not match the pattern, including a valid U+FFFD, and invalid bytes are passed through as is instead of being rewritten as U+FFFD. As a consequence, Translate("hel\uFFFDlo", "^\uFFFD", "H") returns "HHH\uFFFDHH" (it returned "HHHHH" before), and Len(Delete(s, pattern)) + Count(s, pattern) == Len(s) now holds for every input.Successor stops a carry in front of a rune of another kind (letter vs. number), which is what Ruby's String#succ does. As before, only ASCII runes are treated as alphanumeric (documented in Successor), so for input which mixes CJK and ASCII the rule applies to the ASCII runes: Successor("中cZ英ZZ文zZ混9zZ9杂99进z位") returns "中cZ英ZZ文zZ混9zZ9杂99进aa位" (it returned "中dA英AA文aA混0aA0杂00进a位" before).Translator API (HasPattern, TranslateRune, reusing a Translator) is covered by tests now; it had none before.Thank you @vitalivo for the two pull requests in this release:
ScrubFull Changelog: https://github.com/huandu/xstrings/compare/v1.5.0...v1.6.0
Per discuss in #56, I decide to change the result of ToCamelCase to make it align with common sense. In the past, ToCamelCase converts camel_case_stri
Per discuss in #56, I decide to change the result of ToCamelCase to make it align with common sense. In the past, ToCamelCase converts camel_case_string to CamelCaseString, in which the first letter is upper case; Starting from this release, ToCamelCase returns camelCaseString instead. If we want to convert string to "upper" camel case, we can use new API ToPascalCase.
If you have any concern, please feel free to send issue to me. Thanks.
Full Changelog: https://github.com/huandu/xstrings/compare/v1.4.0...v1.5.0
Nothing published for this version
As ToCamelCase is a port of RoR's String#camelize, this change makes the return value of this method consistent with its origin. Thanks @dbainbri-cien
As ToCamelCase is a port of RoR's String#camelize, this change makes the return value of this method consistent with its origin. Thanks @dbainbri-ciena for raising this issue in #54.
This is a breaking API change. The return value of ToCamelCase("toCamelCase") was Tocamelcase and then it's ToCamelCase now. If this change breaks your code, please let me know and open new issue against this change. Thanks.
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
See #46 for details. Thanks, @ninedraft.
See #46 for details. Thanks, @ninedraft.
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
refs #1 : fix an edge case and increase test coverage
refs #1: fix an edge case and increase test coverage
Per @Ilyes512's request in #45, ToCamelCase is aware of space and hyphen now. The conversion rule is updated in #1. ToSnakeCase and ToKebabCase are up
Per @Ilyes512's request in #45, ToCamelCase is aware of space and hyphen now. The conversion rule is updated in #1. ToSnakeCase and ToKebabCase are updated to convert all unicode space, including tab, CR, LF, etc, to underscore or hyphen according to the new rule.
Merge pull request #44 from huandu/issue-ToCamelCase-fail-to-convert-…
Merge pull request #44 from huandu/issue-ToCamelCase-fail-to-convert-…
Nothing published for this version
I add a new method `ToKababCase` as mentioned in #41 per @Ilyes512's request.
I add a new method ToKababCase as mentioned in #41 per @Ilyes512's request.
I also fix some issues #36 #38 #39 in this release. Thanks all guys who raised these issues to me.
I upgrade ToCamelCase to support cases mentioned in #34 per @jhayotte's request.
I upgrade ToCamelCase to support cases mentioned in #34 per @jhayotte's request.
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
One column per quarter.