character-encoding

PostgreSQL encoding issue while executing query from command line

我与影子孤独终老i 提交于 2019-12-22 15:04:59
问题 I am trying to execute an SQL query which is stored in the file. I am using following command to execute: psql -d DB_NAME -a -f QUERY_NAME.sql I have some non English text in the SQL file like - સુરત When the query is executed the text in the database looks like - à ª¸à «Âà ª°à ª¤ How do I execute the query from command line so that it runs correctly? 回答1: Make sure the client_encoding matches the encoding of your file. Check your system locale. Then use a matching command line

Using m4 to convert a string to ASCII codepoints

一曲冷凌霜 提交于 2019-12-22 14:44:07
问题 This should be possible, but as I am a novice with m4, I'm not sure how to go about it, or how to write an algorithm to do so (in m4). edit: Just solved it, anyway for future reference, I have a series of characters, they need to be translated to their equivalent ASCII code points, e.g. ascii(-{COLON}-, -{:}-) => #define TKN_COLON 58 回答1: For the benefit of others interested in a pure m4 implementation I've managed to create the following conversion macro. It has to meddle with the quoting

What charset to use when reading in a java source file?

我怕爱的太早我们不能终老 提交于 2019-12-22 14:17:30
问题 I was reading this Should source code be saved in UTF-8 format and I am using the eclipse compiler lib but need to read some java source files in to feed it to that library. IT seems it can be stored in different formats from that post. Is there one Charset I can use to read it in so it works every time. Charset.forName("UTF-8") maybe? thanks, Dean 回答1: Character encodings vary Any tool can write Java source code in any encoding. Even the idea of .java file is not defined by the Java Language

Inno Setup installator has wrong text encoding

◇◆丶佛笑我妖孽 提交于 2019-12-22 13:56:47
问题 My installator (Inno Setup) has a bad Russian text encoding for the some Windows installations. All machines have Windows XP SP3 (English version), but on some this works, some does not have. There are any settings on Windows to fix it? Thanks 回答1: My guess is that you are using the Non-Unicode version of Inno Setup. The machines, where the installer has wrong encoding, probably do not have the Russian set as the legacy (non-Unicode) encoding. In Windows XP Control panel, check the "Regional

How to set the JVM charset on the command line?

十年热恋 提交于 2019-12-22 12:38:38
问题 What's the command to set the JVM's character set? (Also, what's the command to view the current JVM's character set, so I know how to reset it back to default after I'm done) Thanks, 回答1: java strings are always utf-16 internally (javadoc link), but you can use -Dfile.encoding=UTF-8 to facilitate reading files with a default charset. Just ensure java has access to that fileset when you set it or it won't start. 回答2: java.nio.charset.Charset.defaultCharset() Will get you the JVM's default

How to set the JVM charset on the command line?

白昼怎懂夜的黑 提交于 2019-12-22 12:38:32
问题 What's the command to set the JVM's character set? (Also, what's the command to view the current JVM's character set, so I know how to reset it back to default after I'm done) Thanks, 回答1: java strings are always utf-16 internally (javadoc link), but you can use -Dfile.encoding=UTF-8 to facilitate reading files with a default charset. Just ensure java has access to that fileset when you set it or it won't start. 回答2: java.nio.charset.Charset.defaultCharset() Will get you the JVM's default

Why is the default encoding in Rails not UTF-8?

痞子三分冷 提交于 2019-12-22 11:46:10
问题 When I use UTF-8 characters (most of the time Turkish characters) in controllers, I have to add #encoding: utf-8 on the top of each controller file. Why doesn't Rails use this as a default? edit: I have learnt that it is not about Rails, it is about Ruby. 回答1: Ruby 2.0 is UTF8 by default. Otherwise you must signify that in 1.9. According to naruse: The default script encoding change. Default script encoding (when magic comment is not specified) is changed into UTF8[#6679] In Ruby 1.9, the

Convert Windows-1252 to UTF-8 with JS

被刻印的时光 ゝ 提交于 2019-12-22 11:31:04
问题 I have some strings in dutch language. I know how to encode them using PHP $str = iconv( "Windows-1252", "UTF-8", $str ); What would be the equivalent in Javascript? 回答1: Windows-1252 is a single-byte encoding, which is pretty convenient: you can just build a lookup table. <?php $s = ''; for ($i = 0; $i < 256; $i++) { $converted = iconv('Windows-1252', 'UTF-8', chr($i)); if ($converted === false) { $s .= "\xef\xbf\xbd"; # UTF-8 replacement character } else { $s .= $converted; } } echo $s;

java char encoding for strange string from API

 ̄綄美尐妖づ 提交于 2019-12-22 11:25:41
问题 I'm having strange issue with a response got from API. I'm using apache HTTP Client to get response. Response header has the following Content-Type=[application/json; charset=utf-16] Transfer-Encoding=[chunked] X-Powered-By=[ASP.NET] // Yes, people using ASP.NET So based on this, when I get response, my response looks like follows 笀∀匀琀愀琀甀猀䌀漀搀攀∀㨀㈀  So I tried the following. String body = "笀∀匀琀愀琀甀猀䌀漀搀攀∀㨀㈀"; String charSetString = "utf-8|utf-16|utf-16le, all possible combination" body = new

HTML Unicode Issue: How to display special characters

为君一笑 提交于 2019-12-22 11:04:20
问题 Currently, I have my webpage set to Unicode/UTF-8. When trying to display a special character (for example, em dash, double arrow, etc), it shows up as a question mark symbol. I cannot change these characters to the HTML entity equivalent. How can I circumvent this issue? 回答1: A question mark in a lozenge, �, indicates a character-level error: the data contains bytes that do no represent any character, according to the character encoding being applied. This typically happens when the document