Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>'?' characters occur when data is going through a Unicode-to-Ansi conversion to an Ansi charset that does not support the Unicode characters being converted.</p> <p>What version of C++Builder are you using? In versions prior to CB2009, you should tell Indy the encoding of the AnsiString data that you are passing in. Indy defaults to ASCII (ie: <code>TIdTextEncoding::ASCII</code>) for most String-based operation. That can be overridden when needed, either with optional <code>AAnsiEncoding</code> parameters, the <code>TIdIOHandler::DefAnsiEncoding</code> property, or the global <code>Idglobal::GIdDefaultAnsiEncoding</code> setting. If you do not specify the correct encoding, the AnsiString data may not be converted to Unicode correctly before then being converted to UTF-8. For example:</p> <pre><code>AContext-&gt;Connection-&gt;IOHandler-&gt;WriteLn(cxMemo1-&gt;Text, TIdTextEncoding_UTF8, TTIdTextEncoding_Default); </code></pre> <p>Or:</p> <pre><code>AContext-&gt;Connection-&gt;IOHandler-&gt;DefAnsiEncoding = TIdTextEncoding_Default; AContext-&gt;Connection-&gt;IOHandler-&gt;WriteLn(cxMemo1-&gt;Text, TIdTextEncoding_UTF8); </code></pre> <p>You can optionally also use the <code>TIdIOHandler::DefStringEncoding</code> property if you do not want to specify the UTF-8 encoding on every call:</p> <pre><code>AContext-&gt;Connection-&gt;IOHandler-&gt;DefStringEncoding = TIdTextEncoding_UTF8; AContext-&gt;Connection-&gt;IOHandler-&gt;WriteLn(cxMemo1-&gt;Text); </code></pre> <p>Now, with that said, the fact that <code>WriteFile()</code> is also sending data that J2ME is not handling correctly tells me that Indy is not the root of the issue. WriteFile() simply dups the raw file data as-is to the connection without any interpretation at all. If you send a UTF-8 encoded file, then UTF-8 encoded octets will be sent to J2ME.</p> <p>I suggest you use a packet sniffer, such as Wireshark, to verify the data that Indy is sending. That will tell you for sure whether Indy is really at fault or not.</p> <p>*PS: notice in the examples above that I use Indy's <code>TIdTextEncoding</code> macros instead of <code>TEncoding</code> directly. This is because Indy's TIdTextEncoding logic works around some bugs in Embarcadero's <code>TEncoding</code> classes. Also, we're going to phase out direct support for <code>TEncoding</code> in Indy 11 and expand on <code>TIdTextEncoding</code> so Indy has more control than Embarcadero offers.</p>
    singulars
    1. This table or related slice is empty.
    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. 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