aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/public/result_format/yql_codec_results.cpp
blob: 911993c0c4a2ad7d2255d38db43c6665e8368d9d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include "yql_codec_results.h"

#include <library/cpp/string_utils/base64/base64.h>

#include <yql/essentials/utils/utf8.h>

namespace NYql {
namespace NResult {

constexpr TStringBuf TYsonResultWriter::VoidString;

void TYsonResultWriter::OnStringScalar(TStringBuf value) {
    if (!IsUtf8(value)) {
        TString encoded = Base64Encode(value);
        Writer.OnBeginList();
        Writer.OnListItem();
        Writer.OnStringScalar(TStringBuf(encoded));
        Writer.OnEndList();
    } else {
        Writer.OnStringScalar(value);
    }
}

}
}