-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
hcl2: add strlen function and update docs. (#14463)
- Loading branch information
Showing
5 changed files
with
47 additions
and
21 deletions.
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,3 @@ | ||
```release-note:improvement | ||
jobspec: Added `strlen` HCL2 function to determine the length of a string | ||
``` |
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
35 changes: 35 additions & 0 deletions
35
website/content/docs/job-specification/hcl2/functions/string/strlen.mdx
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,35 @@ | ||
--- | ||
layout: docs | ||
page_title: strlen - Functions - Configuration Language | ||
description: The strlen function determines the length of a string. | ||
--- | ||
|
||
# `strlen` Function | ||
|
||
`strlen` determines the length of a given string. | ||
|
||
```hcl | ||
strlen(string) | ||
``` | ||
|
||
## Examples | ||
|
||
```shell-session | ||
> length("hello") | ||
5 | ||
``` | ||
|
||
When given a string, the result is the number of characters, rather than the | ||
number of bytes or Unicode sequences that form them: | ||
|
||
```shell-session | ||
> length("👾🕹️") | ||
2 | ||
``` | ||
|
||
A "character" is a _grapheme cluster_, as defined by | ||
[Unicode Standard Annex #29](http://unicode.org/reports/tr29/). Note that | ||
remote APIs may have a different definition of "character" for the purpose of | ||
length limits on string arguments; a Nomad provider is responsible for | ||
translating Nomad's string representation into that used by its respective | ||
remote system and applying any additional validation rules to it. |
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