Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(vrl): decode_charset.cue, encode_charset.cue documentations #21981

Merged
merged 2 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions website/cue/reference/remap/functions/decode_charset.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package metadata

remap: functions: decode_charset: {
category: "Codec"
description: """
Decodes the `value` (a non-UTF8 string) to a UTF8 string using the specified [character set](\(urls.charset_standard)).
"""

arguments: [
{
name: "value"
description: "The non-UTF8 string to decode."
required: true
type: ["string"]
},
{
name: "from_charset"
description: "The [character set](\(urls.charset_standard)) to use when decoding the data."
required: true
type: ["string"]

},
]
internal_failure_reasons: [
"`from_charset` isn't a valid [character set](\(urls.charset_standard)).",
]
return: types: ["string"]

examples: [
{
title: "Decode EUC-KR string"
source: """
decode_charset!(decode_base64!("vsiz58fPvLy/5A=="), "euc-kr")
"""
return: "안녕하세요"
},
{
title: "Decode EUC-JP string"
source: """
decode_charset!(decode_base64!("pLOk86TLpMGkzw=="), "euc-jp")
"""
return: "こんにちは"
},
{
title: "Decode GB2312 string"
source: """
decode_charset!(decode_base64!("xOO6ww=="), "gb2312")
"""
return: "你好"
},
]
}
52 changes: 52 additions & 0 deletions website/cue/reference/remap/functions/encode_charset.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package metadata

remap: functions: encode_charset: {
category: "Codec"
description: """
Encodes the `value` (a UTF8 string) to a non-UTF8 string using the specified [character set](\(urls.charset_standard)).
"""

arguments: [
{
name: "value"
description: "The UTF8 string to encode."
required: true
type: ["string"]
},
{
name: "to_charset"
description: "The [character set](\(urls.charset_standard)) to use when encoding the data."
required: true
type: ["string"]

},
]
internal_failure_reasons: [
"`to_charset` isn't a valid [character set](\(urls.charset_standard)).",
]
return: types: ["string"]

examples: [
{
title: "Encode UTF8 string to EUC-KR"
source: """
encode_base64(encode_charset!("안녕하세요", "euc-kr"))
"""
return: "vsiz58fPvLy/5A=="
},
{
title: "Encode UTF8 string to EUC-JP"
source: """
encode_base64(encode_charset!("こんにちは", "euc-jp"))
"""
return: "pLOk86TLpMGkzw=="
},
{
title: "Encode UTF8 string to GB2312"
source: """
encode_base64(encode_charset!("你好", "gb2312"))
"""
return: "xOO6ww=="
},
]
}
1 change: 1 addition & 0 deletions website/cue/reference/urls.cue
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ urls: {
b_tree_map: "https://doc.rust-lang.org/std/collections/struct.BTreeMap.html"
cargo_audit: "\(github)/RustSec/cargo-audit"
centos: "https://www.centos.org/"
charset_standard: "\(encoding_standard)#names-and-labels"
chrono_time_formats: "https://docs.rs/chrono/latest/chrono/format/strftime/index.html#specifiers"
cgroups_limit_resources: "https://the.binbashtheory.com/control-resources-cgroups/"
clickhouse: "https://clickhouse.com/"
Expand Down
Loading