-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
88 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- | ||
title: strings.RuneCount | ||
description: Determines the number of runes in a string. | ||
godocref: | ||
date: 2018-06-01 | ||
publishdate: 2018-06-01 | ||
lastmod: 2018-06-01 | ||
categories: [functions] | ||
menu: | ||
docs: | ||
parent: "functions" | ||
keywords: [counting, character count, length, rune length, rune count] | ||
signature: ["strings.RuneCount INPUT"] | ||
workson: [] | ||
hugoversion: | ||
relatedfuncs: ["len", "countrunes"] | ||
deprecated: false | ||
aliases: [] | ||
--- | ||
|
||
In contrast with `strings.CountRunes` function, which strips HTML and whitespace before counting runes, `strings.RuneCount` simply counts all the runes in a string. It relies on the Go [`utf8.RuneCountInString`] function. | ||
|
||
``` | ||
{{ "Hello, 世界" | strings.RuneCount }} | ||
<!-- outputs a content length of 9 runes. --> | ||
``` | ||
|
||
[`utf8.RuneCount`]: https://golang.org/pkg/unicode/utf8/#RuneCount |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
019bd55
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, just noticed this. The naming is very confusing IMO.. RuneCount vs CountRunes?? Really? How can anyone remember which is which?
I'd suggest having a more descriptive name for the new function to distinguish from the other.
019bd55
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kaushalmodi we have had this discussion. And for future reference, I almost never read comments on merged (i.e. done) branches.