string-parsing

How to Convert Persian Digits in variable to English Digits Using Culture?

心已入冬 提交于 2019-12-03 06:42:02
问题 I want to change persian numbers which are saved in variable like this : string Value="۱۰۳۶۷۵۱"; to string Value="1036751"; How can I use easy way like culture info to do this please? my sample code is: List<string> NERKHCOlist = new List<string>(); NERKHCOlist = ScrappingFunction(NERKHCO, NERKHCOlist); int NERKHCO_Price = int.Parse(NERKHCOlist[0]);//NERKHCOlist[0]=۱۰۳۶۷۵۱ <= So it can not Parsed it to int And This is in my function which retun a list with persian digits inside list items

Determine if a String is a number and convert in Java?

纵然是瞬间 提交于 2019-12-03 05:08:47
问题 I know variants of this question have been asked frequently before (see here and here for instance), but this is not an exact duplicate of those. I would like to check if a String is a number, and if so I would like to store it as a double . There are several ways to do this, but all of them seem inappropriate for my purposes. One solution would be to use Double.parseDouble(s) or similarly new BigDecimal(s) . However, those solutions don't work if there are commas present (so "1,234" would

Best way to extract last segment of URI in Ruby

社会主义新天地 提交于 2019-12-03 05:00:26
Given URI strings like: http://www.somesite.com/abc http://www.somesite.com/alpha/beta/abc http://www.somesite.com/alpha/abc What's the most elegant way in Ruby to grab the abc at the end of these URIs? I would use a proper URI parser like the one of the URI module to get the path from the URI. Then split it at / and get the last part of it: require 'uri' URI(uri).path.split('/').last saihgala uri.split('/')[-1] or uri.split('/').last Try these: if url =~ /\/(.+?)$/ last = $1 end Or last = File.basename(url) From the Terminal command line: ruby -ruri -e "print File.basename(URI.parse('$URI')

How to Convert Persian Digits in variable to English Digits Using Culture?

谁说胖子不能爱 提交于 2019-12-02 20:19:25
I want to change persian numbers which are saved in variable like this : string Value="۱۰۳۶۷۵۱"; to string Value="1036751"; How can I use easy way like culture info to do this please? my sample code is: List<string> NERKHCOlist = new List<string>(); NERKHCOlist = ScrappingFunction(NERKHCO, NERKHCOlist); int NERKHCO_Price = int.Parse(NERKHCOlist[0]);//NERKHCOlist[0]=۱۰۳۶۷۵۱ <= So it can not Parsed it to int And This is in my function which retun a list with persian digits inside list items protected List<string> ScrappingFunction(string SiteAddress, List<string> NodesList) { string Price =

C# Windows form - parsing string received from serial port

余生长醉 提交于 2019-12-02 17:40:36
问题 I'm developing a Windows Form application using C#, in which I receive data from the serial port and for now I have the following code (this is just the relevant code for my problem): private void serialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e) { ReceivedData = serialPort1.ReadExisting(); this.Invoke(new EventHandler(interp_string)); } private void interp_string(object sender, EventArgs e) { textReceive.Text += ReceivedData + "\n"; } But now I need to parse the received

Determine if a String is a number and convert in Java?

怎甘沉沦 提交于 2019-12-02 17:33:58
I know variants of this question have been asked frequently before (see here and here for instance), but this is not an exact duplicate of those. I would like to check if a String is a number, and if so I would like to store it as a double . There are several ways to do this, but all of them seem inappropriate for my purposes. One solution would be to use Double.parseDouble(s) or similarly new BigDecimal(s) . However, those solutions don't work if there are commas present (so "1,234" would cause an exception). I could of course strip out all commas before using these techniques, but that would

Check if dictionary contains substring?

 ̄綄美尐妖づ 提交于 2019-12-01 23:24:55
问题 Say I have two dictionaries with the following key value pairs: 1, "Hello" 2, "Example" And another dictionary as follows: 1, "HelloWorld" 2, "Example2" I want to find out if these dictionaries contain the substring "hello" within them. dictionary.ContainsValue("Hello") will work for the first example but not the second one. How can I check for existence of a substring in all values in a dictionary? 回答1: Just use Any to to check for the first Value that contains "Hello" dictionary.Any(kvp=

write text file mix between arabic and english

ε祈祈猫儿з 提交于 2019-12-01 21:28:55
问题 i'm trying to write in text file sentences that contains Arabic and English but the problem that both languages have direction RTL and LTR so the output text file don't save the order of the words and some words come before each other that is wrong, the problem fixed when i change the text direction from the notepad or any text editor, is there any way to fix this using java? 回答1: As I explained in my comment on your previous question, Unicode text files store the characters in logical order.

write text file mix between arabic and english

江枫思渺然 提交于 2019-12-01 20:16:22
i'm trying to write in text file sentences that contains Arabic and English but the problem that both languages have direction RTL and LTR so the output text file don't save the order of the words and some words come before each other that is wrong, the problem fixed when i change the text direction from the notepad or any text editor, is there any way to fix this using java? As I explained in my comment on your previous question, Unicode text files store the characters in logical order. There is a documented algorithm for how to handle bidirectional text, and control characters you can insert

No Member named stoi in namespace std

半腔热情 提交于 2019-12-01 17:37:48
I am testing out std::stoi function found in the link below: http://en.cppreference.com/w/cpp/string/basic_string/stol but I got the error: No Member named stoi in namespace std. What should I do? Please advise thanks. P.S: I am using Xcode Ide to do my c++. #include <iostream> #include <string> int main() { std::string test = "45"; int myint = std::stoi(test); std::cout << myint << '\n'; } Image First of all, you need a compiler that supports C++11 and you need to compile in "C++11 mode" (in some cases). Secondly, if this is in fact an intellisense issue (and it looks like it may be), then it