Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uses "%ls" if isUTF16Encoded for print/trace #880

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/hx/StdLibs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,16 +288,30 @@ void __trace(Dynamic inObj, Dynamic info)
hx::strbuf convertBuf;
if (info==null())
{
#if defined(HX_SMART_STRINGS) && defined(HX_WINDOWS)
if (text.isUTF16Encoded())
PRINTF("?? %ls\n",text.raw_ptr() ? (wchar_t*)text.__w : L"null");
else
PRINTF("?? %s\n", text.raw_ptr() ? text.__s : "null");
#else
PRINTF("?? %s\n", text.raw_ptr() ? text.out_str(&convertBuf) : "null");
#endif
}
else
{
const char *filename = Dynamic((info)->__Field(HX_CSTRING("fileName"), HX_PROP_DYNAMIC))->toString().utf8_str(0,false);
int line = Dynamic((info)->__Field( HX_CSTRING("lineNumber") , HX_PROP_DYNAMIC))->__ToInt();

hx::strbuf convertBuf;
#if defined(HX_SMART_STRINGS) && defined(HX_WINDOWS)
if (text.isUTF16Encoded())
PRINTF("%s:%d: %ls\n", filename, line, text.raw_ptr() ? (wchar_t*)text.__w : L"null");
else
PRINTF("%s:%d: %s\n", filename, line, text.raw_ptr() ? text.__s : "null");
#else
//PRINTF("%s:%d: %s\n", filename, line, text.raw_ptr() ? text.out_str(&convertBuf) : "null");
PRINTF("%s:%d: %s\n", filename, line, text.raw_ptr() ? text.out_str(&convertBuf) : "null");
#endif
}

}
Expand Down Expand Up @@ -573,14 +587,28 @@ Array<String> __get_args()

void __hxcpp_print_string(const String &inV)
{
#if defined(HX_SMART_STRINGS) && defined(HX_WINDOWS)
if (inV.isUTF16Encoded())
PRINTF("%ls", (wchar_t*)inV.__w);
else
PRINTF("%s", inV.__s);
#else
hx::strbuf convertBuf;
PRINTF("%s", inV.out_str(&convertBuf) );
#endif
}

void __hxcpp_println_string(const String &inV)
{
#if defined(HX_SMART_STRINGS) && defined(HX_WINDOWS)
if (inV.isUTF16Encoded())
PRINTF("%ls\n", (wchar_t*)inV.__w);
else
PRINTF("%s\n", inV.__s);
#else
hx::strbuf convertBuf;
PRINTF("%s\n", inV.out_str(&convertBuf));
#endif
}


Expand Down