character

Special characters in object making JSON invalid (DataContractJsonSerializer)

一世执手 提交于 2019-12-23 04:03:31
问题 I'm trying to serialize an object which has a special character in on of his strings (like ø or æ). The problem is that when I use a special character like that, the last bit of my JSON is cut off? Without special characters: {"availability":"busy","name":"test","visibility":"public"} With special characters: {"availability":"busy","name":"tøst","visibility":"public" I notice that for each special character, a character is cut off of my JSON string. I use following code to serialize: //

Special characters in object making JSON invalid (DataContractJsonSerializer)

不想你离开。 提交于 2019-12-23 04:03:01
问题 I'm trying to serialize an object which has a special character in on of his strings (like ø or æ). The problem is that when I use a special character like that, the last bit of my JSON is cut off? Without special characters: {"availability":"busy","name":"test","visibility":"public"} With special characters: {"availability":"busy","name":"tøst","visibility":"public" I notice that for each special character, a character is cut off of my JSON string. I use following code to serialize: //

Replace new line (\n) character in csv file - spark scala

跟風遠走 提交于 2019-12-23 03:52:00
问题 Just to illustrate the problem I have taken a testset csv file. But in real case scenario, the problem has to handle more than a TeraByte data. I have a CSV file, where the columns are enclosed by quotes("col1"). But when the data import was done. One column contains new line character(\n). This is leading me to lot of problems, when I want to save them as Hive tables. My idea was to replace the \n character with "|" pipe in spark. I achieved so far : 1. val test = sqlContext.load( "com

Conditionally Remove Character of a Vector Element in R

北慕城南 提交于 2019-12-23 03:12:32
问题 I have (sometimes incomplete) data on addresses that looks like this: data <- c("1600 Pennsylvania Avenue, Washington DC", ",Siem Reap,FC,", "11 Wall Street, New York, NY", ",Addis Ababa,FC,") I need to remove the first and/or last character if either one of them are a comma. So far, I have: for(i in 1:length(data)){ lastchar <- nchar(data[i]) sec2last <- nchar(data[i]) - 1 if(regexpr(",",data[i])[1] == 1){ data[i] <- substr(data[i],2, lastchar) } if(regexpr(",",data[i])[1] == nchar(data[i]))

Boost Spirit char parser

血红的双手。 提交于 2019-12-23 02:44:43
问题 Here is a code sample: // file main.cpp #include <iostream> #include <boost/tuple/tuple.hpp> #include <boost/tuple/tuple_io.hpp> #include <boost/spirit/include/qi.hpp> int main() { std::string s( "1 A" ); boost::tuple<double, char> p; complex_matrix_parser::iterator b = s.begin(); complex_matrix_parser::iterator e = s.end(); qi::phrase_parse( b, e, ( qi::double_ >> qi::char_('A') ), qi::space, qi::skip_flag::postskip, p ); std::cerr << "==== " << p << std::endl; return 0; } This should print

convert user input to array of Ints in swift

爷,独闯天下 提交于 2019-12-23 02:31:35
问题 I'm trying to make a simple iOS game to learn programming in swift. The user inputs a 4 digits number in a text field (keyboard type number pad if that matters) and my program should take that 4 digits number and put each digit in an array. basically I want something like userInput = "1234" to become inputArray = [1,2,3,4] I know converting a string to an array of characters is very easy in swift var text : String = "BarFoo" var arrayText = Array(text) //returns ["B","a","r","F","o","o"] my

How to display remaining textbox characters in a label in C#?

风流意气都作罢 提交于 2019-12-22 17:52:46
问题 I'm not sure if I have the last bit right? I changed the max length of the textbox to 140. I can't seem to use TextLength . Help please?! I have this so far: protected void textBox_TextChanged(object sender, EventArgs e) { characterCountLabel.Text = textBox.MaxLength - textBox.TextLength; } 回答1: characterCountLabel.Text is in string format. So you might want to convert it before you set its value like this: protected void textBox_TextChanged(object sender, EventArgs e) { characterCountLabel

Separate string into list in r

人盡茶涼 提交于 2019-12-22 16:46:47
问题 I have a string in R that looks like this: "{[PP]}{[BGH]}{[AC]}{[ETL]}....{[D]}" I want to convert it into a list so that: List[[1]] = {[PP]} List[[2]] = {[BGH]} .... List[[N]] = {[D]} If there were commas you could do strsplit but I want to keep the brackets and not get rid of them. Not sure how to do this in R 回答1: without regular expressions: s <- "{[PP]}{[BGH]}{[AC]}{[ETL]}{[D]}" as.list(paste("{", strsplit(s, "\\{")[[1]][-1], sep = "")) [[1]] [1] "{[PP]}" [[2]] [1] "{[BGH]}" [[3]] [1] "{

Problem with special characters

拥有回忆 提交于 2019-12-22 13:51:53
问题 How can I change the font on android to allow to show special characters like "'" or "à"? Actually the strings that contains these characters are stored in the sqlite database. 回答1: When you load the text into your TextView , will this work for you? textView.setText(new String(textFromDatabase, "UTF-8")); This uses the String constructor to set the charset name. You can change "UTF-8" to a different Character encoding -- Also, look at the javadoc for String. String(byte[] bytes, String

Mysql doesn't display right single quotation mark(’) after inserted into table

萝らか妹 提交于 2019-12-22 12:27:10
问题 I have a table called "Testing". I inserted a row which contains unicode character right single quotation ( ' ) 0x2019 in name field. SQL : //insert into Testing values(Sno,Name,Address) insert into Testing values(1,"**Rajesh’s Friend**","Cumbum"); When listing the same row in Mysql Query Browser or CommandLine . It displays as a normal ANSI character( ' ) instead of being unicode character. I want to display the same unicode character in MySQL table. 回答1: You can try ALTER TABLE Testing