Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Also try this:</p> <pre><code>int main() { //simple string creation string a = "test"; const char* cStr = a.c_str(); //should print out "test" cout &lt;&lt; cStr &lt;&lt; endl; return(DSL_OKAY); } </code></pre> <p>If the <code>const char*</code> line does not cause a compiler error, then we know that <code>std::str</code> is an 8 bit string. If the <code>cout</code> doesn't cause a compiler error, then we know that <code>cout</code> is defined for 8 bit chars. (And if the program produces the same result, then we're still confused :-}</p> <p><strong>EDIT</strong> (based on your comment below): I notice that the buggy output from "test" works out to 9 characters -- "▀ÇΦy♠≈6 ♦". Try other "test" strings such as, oh, "retest" or "foo". I suspect that your output will generally be 2x or 2x+1 the number of chars in the original string (12 or 13 for "retest", 6 or 7 for "foo".) This suggests that you're feeding 16-bit strings into an 8-bit buffer. I don't know how you can be getting that past the compiler, though -- perhaps you've got a faulty or out-of-date definition for std::string and/or cout?</p> <p><strong>EDIT 2</strong>: I remember where I've seen this before. A couple of years ago, I saw an issue where the DOS console window was corrupting the program's output. (I don't remember the exact details, but I think the problem was that the DOS console couldn't handle UTF-8 character sets.) If you're seeing this output in a DOS window (or, less likely, if it's being piped via <code>system()</code> to another program), then try re-directing it to a file, then open that file with Notepad. It just might work...</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload