diff options
author | Gavin Andresen <gavinandresen@gmail.com> | 2013-10-22 01:20:02 -0700 |
---|---|---|
committer | Gavin Andresen <gavinandresen@gmail.com> | 2013-10-22 01:20:02 -0700 |
commit | 125bdead3e9be9a6ce23129409612a4d8501980b (patch) | |
tree | 9b87499106f280a32edab404351c5b7e3835e046 /src/bitcoinrpc.cpp | |
parent | 8435f7b8ee2521d11364f400cf63e9fb3f2c8a7d (diff) | |
parent | 2ecb7555a9df1e843fd25f588819e4ca1d94b266 (diff) | |
download | bitcoin-125bdead3e9be9a6ce23129409612a4d8501980b.tar.xz |
Merge pull request #2740 from constantined/constantined
UTF-8 support for JSON-RPC
Diffstat (limited to 'src/bitcoinrpc.cpp')
-rw-r--r-- | src/bitcoinrpc.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp index f2a52e92ed..93ab9a4770 100644 --- a/src/bitcoinrpc.cpp +++ b/src/bitcoinrpc.cpp @@ -31,6 +31,8 @@ using namespace boost; using namespace boost::asio; using namespace json_spirit; +static const char* Value_type_name[]={"obj", "array", "str", "bool", "int", "real", "null"}; + static std::string strRPCUserColonPass; // These are created by StartRPCThreads, destroyed in StopRPCThreads @@ -531,7 +533,7 @@ string JSONRPCRequest(const string& strMethod, const Array& params, const Value& request.push_back(Pair("method", strMethod)); request.push_back(Pair("params", params)); request.push_back(Pair("id", id)); - return write_string(Value(request), false) + "\n"; + return write_string(Value(request), raw_utf8) + "\n"; } Object JSONRPCReplyObj(const Value& result, const Value& error, const Value& id) @@ -549,7 +551,7 @@ Object JSONRPCReplyObj(const Value& result, const Value& error, const Value& id) string JSONRPCReply(const Value& result, const Value& error, const Value& id) { Object reply = JSONRPCReplyObj(result, error, id); - return write_string(Value(reply), false) + "\n"; + return write_string(Value(reply), raw_utf8) + "\n"; } void ErrorReply(std::ostream& stream, const Object& objError, const Value& id) @@ -980,7 +982,7 @@ static string JSONRPCExecBatch(const Array& vReq) for (unsigned int reqIdx = 0; reqIdx < vReq.size(); reqIdx++) ret.push_back(JSONRPCExecOne(vReq[reqIdx])); - return write_string(Value(ret), false) + "\n"; + return write_string(Value(ret), raw_utf8) + "\n"; } void ServiceConnection(AcceptedConnection *conn) @@ -1282,7 +1284,7 @@ int CommandLineRPC(int argc, char *argv[]) if (error.type() != null_type) { // Error - strPrint = "error: " + write_string(error, false); + strPrint = "error: " + write_string(error, raw_utf8); int code = find_value(error.get_obj(), "code").get_int(); nRet = abs(code); } @@ -1294,7 +1296,7 @@ int CommandLineRPC(int argc, char *argv[]) else if (result.type() == str_type) strPrint = result.get_str(); else - strPrint = write_string(result, true); + strPrint = write_string(result, pretty_print | raw_utf8); } } catch (boost::thread_interrupted) { |