From b73f9df65cbaae8d70d9849d89a8ddc8e48b62f5 Mon Sep 17 00:00:00 2001 From: Igor Hatarist Date: Wed, 14 Dec 2016 13:01:33 +0300 Subject: [PATCH] Improved toStringCutToZero description & added an example --- doc/reference_en.html | 17 ++++++++++++++++- doc/reference_ru.html | 17 ++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/doc/reference_en.html b/doc/reference_en.html index 72930d2fbfa..0077fcc2418 100644 --- a/doc/reference_en.html +++ b/doc/reference_en.html @@ -4573,7 +4573,22 @@ Converts a String type argument to a FixedString(N) type (a string with fixed le ===toStringCutToZero(s)=== -Accepts a String or FixedString argument. Returns a String and removes the null bytes from the end of the string. +Accepts a String or FixedString argument. Returns a String that is cut to a first null byte occurrence. + +Example: +%% +:) SELECT toFixedString('foo', 8) AS s, toStringCutToZero(s) AS s_cut + +┌─s─────────────┬─s_cut─┐ +│ foo\0\0\0\0\0 │ foo │ +└───────────────┴───────┘ + +:) SELECT toFixedString('foo\0bar', 8) AS s, toStringCutToZero(s) AS s_cut + +┌─s──────────┬─s_cut─┐ +│ foo\0bar\0 │ foo │ +└────────────┴───────┘ +%% ===reinterpretAsUInt8, reinterpretAsUInt16, reinterpretAsUInt32, reinterpretAsUInt64=== ===reinterpretAsInt8, reinterpretAsInt16, reinterpretAsInt32, reinterpretAsInt64=== diff --git a/doc/reference_ru.html b/doc/reference_ru.html index 3e1afe9bd78..c0e32887b5b 100644 --- a/doc/reference_ru.html +++ b/doc/reference_ru.html @@ -4637,7 +4637,22 @@ SELECT ===toStringCutToZero(s)=== -Принимает аргумент типа String или FixedString. Возвращает String, удаляя нулевые байты с конца строки. +Принимает аргумент типа String или FixedString. Возвращает String, вырезая содержимое строки до первого найденного нулевого байта. + +Пример: +%% +:) SELECT toFixedString('foo', 8) AS s, toStringCutToZero(s) AS s_cut + +┌─s─────────────┬─s_cut─┐ +│ foo\0\0\0\0\0 │ foo │ +└───────────────┴───────┘ + +:) SELECT toFixedString('foo\0bar', 8) AS s, toStringCutToZero(s) AS s_cut + +┌─s──────────┬─s_cut─┐ +│ foo\0bar\0 │ foo │ +└────────────┴───────┘ +%% ===reinterpretAsUInt8, reinterpretAsUInt16, reinterpretAsUInt32, reinterpretAsUInt64=== ===reinterpretAsInt8, reinterpretAsInt16, reinterpretAsInt32, reinterpretAsInt64===