summaryrefslogtreecommitdiff
path: root/src/common/string_util.cpp
diff options
context:
space:
mode:
authorGravatar darkf2014-12-29 19:47:41 -0800
committerGravatar darkf2014-12-29 19:47:41 -0800
commit8ba9ac0f74abb0408a26207a76a0c1808bad8de0 (patch)
treef1c7c3393fa726435b5b90bf335567c93e528ef1 /src/common/string_util.cpp
parentAdd comment regarding __WIN32__ in SkyEye code (diff)
parentMerge pull request #367 from bunnei/usat_ssat (diff)
downloadyuzu-8ba9ac0f74abb0408a26207a76a0c1808bad8de0.tar.gz
yuzu-8ba9ac0f74abb0408a26207a76a0c1808bad8de0.tar.xz
yuzu-8ba9ac0f74abb0408a26207a76a0c1808bad8de0.zip
Fix merge conflicts
Diffstat (limited to 'src/common/string_util.cpp')
-rw-r--r--src/common/string_util.cpp32
1 files changed, 16 insertions, 16 deletions
diff --git a/src/common/string_util.cpp b/src/common/string_util.cpp
index 1ca2dfb39..0dd2d2349 100644
--- a/src/common/string_util.cpp
+++ b/src/common/string_util.cpp
@@ -1,8 +1,8 @@
1// Copyright 2013 Dolphin Emulator Project 1// Copyright 2013 Dolphin Emulator Project / 2014 Citra Emulator Project
2// Licensed under GPLv2 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <algorithm> 5#include <boost/range/algorithm.hpp>
6 6
7#include "common/common.h" 7#include "common/common.h"
8#include "common/string_util.h" 8#include "common/string_util.h"
@@ -18,20 +18,20 @@ namespace Common {
18 18
19/// Make a string lowercase 19/// Make a string lowercase
20std::string ToLower(std::string str) { 20std::string ToLower(std::string str) {
21 std::transform(str.begin(), str.end(), str.begin(), ::tolower); 21 boost::transform(str, str.begin(), ::tolower);
22 return str; 22 return str;
23} 23}
24 24
25/// Make a string uppercase 25/// Make a string uppercase
26std::string ToUpper(std::string str) { 26std::string ToUpper(std::string str) {
27 std::transform(str.begin(), str.end(), str.begin(), ::toupper); 27 boost::transform(str, str.begin(), ::toupper);
28 return str; 28 return str;
29} 29}
30 30
31// faster than sscanf 31// faster than sscanf
32bool AsciiToHex(const char* _szValue, u32& result) 32bool AsciiToHex(const char* _szValue, u32& result)
33{ 33{
34 char *endptr = NULL; 34 char *endptr = nullptr;
35 const u32 value = strtoul(_szValue, &endptr, 16); 35 const u32 value = strtoul(_szValue, &endptr, 16);
36 36
37 if (!endptr || *endptr) 37 if (!endptr || *endptr)
@@ -69,7 +69,7 @@ bool CharArrayFromFormatV(char* out, int outsize, const char* format, va_list ar
69 // will be present in the middle of a multibyte sequence. 69 // will be present in the middle of a multibyte sequence.
70 // 70 //
71 // This is why we lookup an ANSI (cp1252) locale here and use _vsnprintf_l. 71 // This is why we lookup an ANSI (cp1252) locale here and use _vsnprintf_l.
72 static locale_t c_locale = NULL; 72 static locale_t c_locale = nullptr;
73 if (!c_locale) 73 if (!c_locale)
74 c_locale = _create_locale(LC_ALL, ".1252"); 74 c_locale = _create_locale(LC_ALL, ".1252");
75 writtenCount = _vsnprintf_l(out, outsize, format, c_locale, args); 75 writtenCount = _vsnprintf_l(out, outsize, format, c_locale, args);
@@ -92,7 +92,7 @@ bool CharArrayFromFormatV(char* out, int outsize, const char* format, va_list ar
92std::string StringFromFormat(const char* format, ...) 92std::string StringFromFormat(const char* format, ...)
93{ 93{
94 va_list args; 94 va_list args;
95 char *buf = NULL; 95 char *buf = nullptr;
96#ifdef _WIN32 96#ifdef _WIN32
97 int required = 0; 97 int required = 0;
98 98
@@ -107,7 +107,7 @@ std::string StringFromFormat(const char* format, ...)
107#else 107#else
108 va_start(args, format); 108 va_start(args, format);
109 if (vasprintf(&buf, format, args) < 0) 109 if (vasprintf(&buf, format, args) < 0)
110 ERROR_LOG(COMMON, "Unable to allocate memory for string"); 110 LOG_ERROR(Common, "Unable to allocate memory for string");
111 va_end(args); 111 va_end(args);
112 112
113 std::string temp = buf; 113 std::string temp = buf;
@@ -162,7 +162,7 @@ std::string StripQuotes(const std::string& s)
162 162
163bool TryParse(const std::string &str, u32 *const output) 163bool TryParse(const std::string &str, u32 *const output)
164{ 164{
165 char *endptr = NULL; 165 char *endptr = nullptr;
166 166
167 // Reset errno to a value other than ERANGE 167 // Reset errno to a value other than ERANGE
168 errno = 0; 168 errno = 0;
@@ -475,7 +475,7 @@ static std::string CodeToUTF8(const char* fromcode, const std::basic_string<T>&
475 iconv_t const conv_desc = iconv_open("UTF-8", fromcode); 475 iconv_t const conv_desc = iconv_open("UTF-8", fromcode);
476 if ((iconv_t)(-1) == conv_desc) 476 if ((iconv_t)(-1) == conv_desc)
477 { 477 {
478 ERROR_LOG(COMMON, "Iconv initialization failure [%s]: %s", fromcode, strerror(errno)); 478 LOG_ERROR(Common, "Iconv initialization failure [%s]: %s", fromcode, strerror(errno));
479 iconv_close(conv_desc); 479 iconv_close(conv_desc);
480 return {}; 480 return {};
481 } 481 }
@@ -510,7 +510,7 @@ static std::string CodeToUTF8(const char* fromcode, const std::basic_string<T>&
510 } 510 }
511 else 511 else
512 { 512 {
513 ERROR_LOG(COMMON, "iconv failure [%s]: %s", fromcode, strerror(errno)); 513 LOG_ERROR(Common, "iconv failure [%s]: %s", fromcode, strerror(errno));
514 break; 514 break;
515 } 515 }
516 } 516 }
@@ -528,10 +528,10 @@ std::u16string UTF8ToUTF16(const std::string& input)
528{ 528{
529 std::u16string result; 529 std::u16string result;
530 530
531 iconv_t const conv_desc = iconv_open("UTF-16", "UTF-8"); 531 iconv_t const conv_desc = iconv_open("UTF-16LE", "UTF-8");
532 if ((iconv_t)(-1) == conv_desc) 532 if ((iconv_t)(-1) == conv_desc)
533 { 533 {
534 ERROR_LOG(COMMON, "Iconv initialization failure [UTF-8]: %s", strerror(errno)); 534 LOG_ERROR(Common, "Iconv initialization failure [UTF-8]: %s", strerror(errno));
535 iconv_close(conv_desc); 535 iconv_close(conv_desc);
536 return {}; 536 return {};
537 } 537 }
@@ -566,7 +566,7 @@ std::u16string UTF8ToUTF16(const std::string& input)
566 } 566 }
567 else 567 else
568 { 568 {
569 ERROR_LOG(COMMON, "iconv failure [UTF-8]: %s", strerror(errno)); 569 LOG_ERROR(Common, "iconv failure [UTF-8]: %s", strerror(errno));
570 break; 570 break;
571 } 571 }
572 } 572 }
@@ -582,7 +582,7 @@ std::u16string UTF8ToUTF16(const std::string& input)
582 582
583std::string UTF16ToUTF8(const std::u16string& input) 583std::string UTF16ToUTF8(const std::u16string& input)
584{ 584{
585 return CodeToUTF8("UTF-16", input); 585 return CodeToUTF8("UTF-16LE", input);
586} 586}
587 587
588std::string CP1252ToUTF8(const std::string& input) 588std::string CP1252ToUTF8(const std::string& input)