summaryrefslogtreecommitdiff
path: root/Source/Core/Common/Src/StringUtil.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Core/Common/Src/StringUtil.cpp')
-rw-r--r--Source/Core/Common/Src/StringUtil.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/Source/Core/Common/Src/StringUtil.cpp b/Source/Core/Common/Src/StringUtil.cpp
index 0233c5e841..b7cb1adb1c 100644
--- a/Source/Core/Common/Src/StringUtil.cpp
+++ b/Source/Core/Common/Src/StringUtil.cpp
@@ -460,3 +460,32 @@ void NormalizeDirSep(std::string* str)
}
#endif
}
+
+std::string TabsToSpaces(int tab_size, const std::string &in)
+{
+ std::string out;
+ int len = 0;
+ // First, compute the size of the new string.
+ for (int i = 0; i < in.size(); i++)
+ {
+ if (in[i] == '\t')
+ len += tab_size;
+ else
+ len += 1;
+ }
+ out.resize(len);
+ int out_ctr = 0;
+ for (int i = 0; i < in.size(); i++)
+ {
+ if (in[i] == '\t')
+ {
+ for (int j = 0; j < tab_size; j++)
+ out[out_ctr++] = ' ';
+ }
+ else
+ {
+ out[out_ctr++] = in[i];
+ }
+ }
+ return out;
+} \ No newline at end of file