source: s10k/CommonLibs/plog/Converters/NativeEOLConverter.h@ 1138

Last change on this file since 1138 was 1073, checked in by s10k, 7 years ago

added XML Tools latest version (2.0d) and s10k's common libs

File size: 1.0 KB
Line 
1#pragma once
2#include <plog/Converters/UTF8Converter.h>
3#include <plog/Util.h>
4
5namespace plog
6{
7 template<class NextConverter = UTF8Converter>
8 class NativeEOLConverter : public NextConverter
9 {
10#ifdef _WIN32
11 public:
12 static std::string header(const util::nstring& str)
13 {
14 return NextConverter::header(fixLineEndings(str));
15 }
16
17 static std::string convert(const util::nstring& str)
18 {
19 return NextConverter::convert(fixLineEndings(str));
20 }
21
22 private:
23 static std::wstring fixLineEndings(const std::wstring& str)
24 {
25 std::wstring output;
26 output.reserve(str.length() * 2);
27
28 for (size_t i = 0; i < str.size(); ++i)
29 {
30 wchar_t ch = str[i];
31
32 if (ch == L'\n')
33 {
34 output.push_back(L'\r');
35 }
36
37 output.push_back(ch);
38 }
39
40 return output;
41 }
42#endif
43 };
44}
Note: See TracBrowser for help on using the repository browser.