Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: Daniele Futtorovic Newsgroups: comp.lang.java.programmer Subject: Re: how do you block the GUI repaints? Date: Wed, 23 May 2018 18:46:12 +0200 Organization: A noiseless patient Spider Lines: 35 Message-ID: References: <2ddef1c1-ac37-4384-a3a5-f9b94a1fcbf6@googlegroups.com> <6762ff5e-8846-4ea7-be57-7518f2d7ff42@googlegroups.com> <593f7f26-0f96-4869-9f55-12917ff65574@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Injection-Date: Wed, 23 May 2018 16:47:06 -0000 (UTC) Injection-Info: h2725194.stratoserver.net; posting-host="21b232232ecdedc4c6b354478bf40cb8"; logging-data="6144"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/1IpnNXYndxPawY7cZkbc5" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 Cancel-Lock: sha1:9SYr5KZp751DU7kZkaA/vBzG6Bo= In-Reply-To: X-Antivirus-Status: Clean Content-Language: en-GB X-Antivirus: AVG (VPS 180523-2, 05/23/2018), Outbound message Xref: csiph.com comp.lang.java.programmer:38287 On 2018-05-23 16:48, Eric Douglas wrote: > On Wednesday, May 23, 2018 at 10:31:07 AM UTC-4, Daniele Futtorovic wrote: >>> >> >> The "squares" appear because the font you're using does not have any >> glyph for the codepoints that you're trying to show. >> >> As for the rest... Good Luck! > > I tried setting the JTextArea font to Lucida Sans Unicode. If that doesn't have a glyph for the characters I don't know what would. None will. Because those aren't characters (or more precisely, the byte-encoded representation of characters). > As I'm just reading files in as byte[] array I was wondering if I need to do some kind of character encoding conversion to create a displayable String, or if I just need to call a method to test for characters that won't display and convert to a hex view. You'll have to know beforehand what encoding your text file is in. There is, to my knowledge, no general-purpose, reliable way of determining the encoding of an arbitrary file (including whether it's text or not). Elsethreads, you talk about "JTextArea's character encoding". JTextArea does not have a character encoding. Once a String is in the Java runtime, it's a String, period. No character encoding. Character encoding has to happen at the boundary of the Java runtime, so to speak, when you are reading external data in (in this case, your file). I would suggest using java.nio.charset.CharsetDecoder-s in combination with the java.nio.channels.FileChannel instance you can obtain from the RandomAccessFile instance (because both work with java.nio.ByteBuffer-s). If you're unfamiliar with character (en|de)coding or Java NIO buffers, I would strongly suggest you look up a tutorial on those. -- DF.