]> git.sesse.net Git - casparcg/commitdiff
Only log non ascii characters as ? in console, but log all characters as UTF-8 to...
authorhellgore <hellgore@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Thu, 7 Jun 2012 13:16:50 +0000 (13:16 +0000)
committerhellgore <hellgore@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Thu, 7 Jun 2012 13:16:50 +0000 (13:16 +0000)
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/trunk@3107 362d55ac-95cf-4e76-9f9a-cbaa9c17b72d

common/log/log.cpp
common/utility/string.cpp
common/utility/string.h
protocol/amcp/AMCPCommandsImpl.cpp
shell/main.cpp

index 5060c559e049f8bfdec326d5a9020b29b0936604..0c7620831c8e837d3f73d59ebbdb2a9394220da5 100644 (file)
@@ -156,10 +156,7 @@ void add_file_sink(const std::wstring& folder)
                        boost::log::keywords::open_mode = std::ios::app\r
                );\r
 \r
-               // TODO: does not seem to affect the character set only date formatting\r
-               file_sink->locked_backend()->imbue(caspar::get_narrow_locale());\r
-               // TODO: when UTF-8 log file output is fixed we can enable this\r
-               bool print_all_characters = false;\r
+               bool print_all_characters = true;\r
 \r
                file_sink->locked_backend()->set_formatter(boost::bind(my_formatter, print_all_characters, _1, _2));\r
 \r
index 1aef547b48865e97a378dcfe49e314066e35ef24..33ba98500234e2be1d094351efef553973b4504e 100644 (file)
@@ -47,14 +47,4 @@ std::string narrow(const std::string& str)
        return str ;\r
 }\r
 \r
-std::locale get_narrow_locale()\r
-{\r
-       boost::locale::generator gen;\r
-\r
-       gen.locale_cache_enabled(true);\r
-\r
-       // TODO: make configurable?\r
-       return gen.generate("en_GB.UTF-8");\r
-}\r
-\r
 }
\ No newline at end of file
index 29fff2b0773823b1b2b7f13e3c9712e465f6b630..a7aee7a8195d7f90f31a067defe26b91deedb16c 100644 (file)
@@ -22,7 +22,6 @@
 #pragma once\r
 \r
 #include <string>\r
-#include <locale>\r
 #include <boost/lexical_cast.hpp>\r
           \r
 namespace caspar {\r
@@ -31,7 +30,6 @@ std::wstring widen(const std::string& str);
 std::wstring widen(const std::wstring& str);\r
 std::string narrow(const std::wstring& str);      \r
 std::string narrow(const std::string& str);\r
-std::locale get_narrow_locale();\r
 \r
 template <typename T>\r
 inline T lexical_cast_or_default(const std::wstring str, T fail_value = T())\r
index f64e893848aa4284083fea8071c2f4a3f1d6b92f..91df432f5b48b7b71ec6e57b507c1888c7e9e7e7 100644 (file)
@@ -981,7 +981,6 @@ bool CGCommand::DoExecuteAdd() {
 \r
                        //open file\r
                        std::wifstream datafile(filename.c_str());\r
-                       datafile.imbue(caspar::get_narrow_locale());\r
 \r
                        if(datafile) \r
                        {\r
@@ -1131,7 +1130,6 @@ bool CGCommand::DoExecuteUpdate()
 \r
                        //open file\r
                        std::wifstream datafile(filename.c_str());\r
-                       datafile.imbue(caspar::get_narrow_locale());\r
 \r
                        if(datafile) \r
                        {\r
@@ -1238,10 +1236,7 @@ bool DataCommand::DoExecuteStore()
        filename.append(_parameters[1]);\r
        filename.append(TEXT(".ftd"));\r
 \r
-       std::wofstream datafile;\r
-\r
-       datafile.imbue(caspar::get_narrow_locale());\r
-       datafile.open(filename.c_str());\r
+       std::wofstream datafile(filename.c_str());\r
 \r
        if(!datafile) \r
        {\r
@@ -1271,8 +1266,6 @@ bool DataCommand::DoExecuteRetrieve()
 \r
        std::wifstream datafile(filename.c_str());\r
 \r
-       datafile.imbue(caspar::get_narrow_locale());\r
-\r
        if(!datafile) \r
        {\r
                SetReplyString(TEXT("404 DATA RETRIEVE ERROR\r\n"));\r
index b381dedfd1d44314de285ab1447e08a96d133efd..7860b74fc772cd6766f7a42bca62cd8c01803d54 100644 (file)
@@ -38,6 +38,8 @@
 #define NOMINMAX\r
 #define WIN32_LEAN_AND_MEAN\r
 \r
+#include <locale>\r
+\r
 #include <windows.h>\r
 #include <winnt.h>\r
 #include <mmsystem.h>\r
@@ -65,6 +67,7 @@
 #include <boost/property_tree/detail/file_parser_error.hpp>\r
 #include <boost/property_tree/xml_parser.hpp>\r
 #include <boost/foreach.hpp>\r
+#include <boost/locale.hpp>\r
 \r
 // NOTE: This is needed in order to make CComObject work since this is not a real ATL project.\r
 CComModule _AtlModule;\r
@@ -79,6 +82,12 @@ void change_icon( const HICON hNewIcon )
    ::FreeLibrary(hMod);\r
 }\r
 \r
+void setup_global_locale()\r
+{\r
+       std::locale loc = boost::locale::generator()("");\r
+       std::locale::global(loc);\r
+}\r
+\r
 void setup_console_window()\r
 {       \r
        auto hOut = GetStdHandle(STD_OUTPUT_HANDLE);\r
@@ -166,6 +175,8 @@ int main(int argc, wchar_t* argv[])
        \r
        SetUnhandledExceptionFilter(UserUnhandledExceptionFilter);\r
 \r
+       setup_global_locale();\r
+\r
        std::wcout << L"Type \"q\" to close application." << std::endl;\r
        \r
        // Set debug mode.\r