mirror of
https://github.com/tiennm99/hugoDocs.git
synced 2026-10-13 22:16:02 +00:00
tpl/strings: strings.RuneCount
This commit is contained in:
1 parent
828ea5f15c
commit
081f8a0f92
2 files changed
+47
-1
No files matched your search
@@ -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
|
||||||
+19
-1
@@ -3146,7 +3146,25 @@
|
|||||||
"Aliases": [
|
"Aliases": [
|
||||||
"countrunes"
|
"countrunes"
|
||||||
],
|
],
|
||||||
"Examples": []
|
"Examples": [
|
||||||
|
[
|
||||||
|
"{{ \"Hello, 世界\" | countrunes }}",
|
||||||
|
"8"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"RuneCount": {
|
||||||
|
"Description": "RuneCount returns the number of runes in s",
|
||||||
|
"Args": [
|
||||||
|
"s"
|
||||||
|
],
|
||||||
|
"Aliases": [],
|
||||||
|
"Examples": [
|
||||||
|
[
|
||||||
|
"{{ \"Hello, 世界\" | strings.RuneCount }}",
|
||||||
|
"9"
|
||||||
|
]
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"CountWords": {
|
"CountWords": {
|
||||||
"Description": "CountWords returns the approximate word count in s.",
|
"Description": "CountWords returns the approximate word count in s.",
|
||||||
|
|||||||
Reference in new issue
Block a user