Unicode
- The configuration file now supports JSON encoding of Unicode characters, by specifying \uNNNN.
This commit is contained in:
@@ -38,6 +38,7 @@
|
||||
#include <Date.h>
|
||||
#include <File.h>
|
||||
#include <Timer.h>
|
||||
#include <JSON.h>
|
||||
#include <Config.h>
|
||||
#include <text.h>
|
||||
#include <util.h>
|
||||
@@ -496,7 +497,7 @@ void Config::parse (const std::string& input, int nest /* = 1 */)
|
||||
std::string key = trim (line.substr (0, equal), " \t"); // no i18n
|
||||
std::string value = trim (line.substr (equal+1, line.length () - equal), " \t"); // no i18n
|
||||
|
||||
(*this)[key] = value;
|
||||
(*this)[key] = json::decode (value);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -551,7 +552,7 @@ void Config::createDefaultRC (const std::string& rc, const std::string& data)
|
||||
<< "\n";
|
||||
|
||||
// Write out the new file.
|
||||
if (! File::write (rc, contents.str ()))
|
||||
if (! File::write (rc, json::encode (contents.str ())))
|
||||
throw format (STRING_CONFIG_BAD_WRITE, rc);
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
#include <Context.h>
|
||||
#include <JSON.h>
|
||||
#include <i18n.h>
|
||||
#include <text.h>
|
||||
#include <util.h>
|
||||
@@ -103,9 +104,9 @@ int CmdConfig::execute (std::string& output)
|
||||
if (confirm (format (STRING_CMD_CONFIG_CONFIRM, name, context.config.get (name), value)))
|
||||
{
|
||||
if (comment != std::string::npos)
|
||||
*line = name + "=" + value + " " + line->substr (comment);
|
||||
*line = name + "=" + json::encode (value) + " " + line->substr (comment);
|
||||
else
|
||||
*line = name + "=" + value;
|
||||
*line = name + "=" + json::encode (value);
|
||||
|
||||
change = true;
|
||||
}
|
||||
@@ -116,7 +117,7 @@ int CmdConfig::execute (std::string& output)
|
||||
if (!found &&
|
||||
confirm (format (STRING_CMD_CONFIG_CONFIRM2, name, value)))
|
||||
{
|
||||
contents.push_back (name + "=" + value);
|
||||
contents.push_back (name + "=" + json::encode (value));
|
||||
change = true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user