encoding

Insert UTF8 data into a SQL Server 2008

你说的曾经没有我的故事 提交于 2019-12-23 09:31:08
问题 I have an issue with encoding. I want to put data from a UTF-8-encoded file into a SQL Server 2008 database. SQL Server only features UCS-2 encoding, so I decided to explicitly convert the retrieved data. // connect to page file _fsPage = new FileStream(mySettings.filePage, FileMode.Open, FileAccess.Read); _streamPage = new StreamReader(_fsPage, System.Text.Encoding.UTF8); Here's the conversion routine for the data: private string ConvertTitle(string title) { string utf8_String = Regex

Encoding issue when using Nokogiri replace

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-23 09:27:41
问题 I have this code: # encoding: utf-8 require 'nokogiri' s = "<a href='/path/to/file'>Café Verona</a>".encode('UTF-8') puts "Original string: #{s}" @doc = Nokogiri::HTML::DocumentFragment.parse(s) links = @doc.css('a') only_text = 'Café Verona'.encode('UTF-8') puts "Replacement text: #{only_text}" links.first.replace(only_text) puts @doc.to_html However, the output is this: Original string: <a href='/path/to/file'>Café Verona</a> Replacement text: Café Verona Café Verona Why does the text in

Defining 4-byte UTF-16 character in a string

≯℡__Kan透↙ 提交于 2019-12-23 09:16:18
问题 I have read a question about UTF-8, UTF-16 and UCS-2 and almost all answers give the statement that UCS-2 is obsolete and C# uses UTF-16. However, all my attempts to create the 4-byte character U+1D11E in C# failed, so I actually think C# uses the UCS-2 subset of UTF-16 only. There are my tries: string s = "\u1D11E"; // gives the 2 character string "ᴑE", because \u1D11 is ᴑ string s = (char) 0x1D11E; // won't compile because of an overflow string s = Encoding.Unicode.GetString(new byte[]

problem using base64 encoder and InputStreamReader

僤鯓⒐⒋嵵緔 提交于 2019-12-23 09:02:30
问题 I have some CLOB columns in a database that I need to put Base64 encoded binary files in. These files can be large, so I need to stream them, I can't read the whole thing in at once. I'm using org.apache.commons.codec.binary.Base64InputStream to do the encoding, and I'm running into a problem. My code is essentially this FileInputStream fis = new FileInputStream(file); Base64InputStream b64is = new Base64InputStream(fis, true, -1, null); BufferedReader reader = new BufferedReader(new

How to URL encode a NSString

我是研究僧i 提交于 2019-12-23 08:56:41
问题 I am trying to url encode a string, but the NSURLConnection is failing because of a 'bad url'. Here is my URL: NSString *address = mp.streetAddress; NSString *encodedAddress = [address stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; NSString *cityState= mp.cityState; NSString *encodedCityState = [cityState stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; NSString *fullAddressURL = [NSString stringWithFormat:@"http://www.zillow.com/webservice

Pandas: save to excel encoding issue

荒凉一梦 提交于 2019-12-23 08:52:50
问题 I have a similar problem to the one mentioned here but none of the suggested methods work for me. I have a medium size utf-8 .csv file with a lot of non-ascii characters. I am splitting the file by a particular value from one of the columns, and then I'd like to save each of the obtained dataframes as an .xlsx file with the characters preserved. This doesn't work, as I am getting an error: UnicodeDecodeError: 'ascii' codec can't decode byte 0xff in position 7: ordinal not in range(128) Here

Pandas: save to excel encoding issue

£可爱£侵袭症+ 提交于 2019-12-23 08:52:07
问题 I have a similar problem to the one mentioned here but none of the suggested methods work for me. I have a medium size utf-8 .csv file with a lot of non-ascii characters. I am splitting the file by a particular value from one of the columns, and then I'd like to save each of the obtained dataframes as an .xlsx file with the characters preserved. This doesn't work, as I am getting an error: UnicodeDecodeError: 'ascii' codec can't decode byte 0xff in position 7: ordinal not in range(128) Here

Java IPv6 Address String to Bytes

左心房为你撑大大i 提交于 2019-12-23 08:06:16
问题 How can I convert a String containing the ipv6's machine packet destination to a 16 byte array? I know about getBytes and encodings, but I can't seem to understand which encoding I should use or if I have to convert that String to Hexadecimal or not. String ipv6 = "2001:0DB8:AC10:FE01:0000:0000:0000:0000"; byte[] bytes = ipv6.getBytes(); //must be a 16 byte array An example of what I wanna do, just to exemplify. Obs.: I have to convert the String to a 16 byte array Thanks 回答1: try this

How do I read characters in a string as their UTF-32 decimal values?

穿精又带淫゛_ 提交于 2019-12-23 07:49:16
问题 I have, for example, this Unicode string, which consists of the Cyclone and the Japanese Castle defined in C# and .NET, which uses UTF-16 for its CLR string encoding: var value = "🌀🏯"; If you check this, you find very quickly that value.Length = 4 because C# uses UTF-16 encoded strings, so for these reasons I can't just loop on each character and get its UTF-32 decimal value: foreach (var character in value) result = (ulong)character; . It begs the question, how can I get the UTF-32 decimal

 characters appended to the beginning of each file

…衆ロ難τιáo~ 提交于 2019-12-23 07:46:37
问题 I've downloaded an HttpHandler class that concatenates JS files into one file and it keeps appending the  characters at the start of each file it concatenates. Any ideas on what is causing this? Could it be that onces the files processed they are written to the cache and that's how the cache is storing/rendering it? Any inputs would be greatly appreciated. using System; using System.Net; using System.IO; using System.IO.Compression; using System.Text; using System.Configuration; using