Search Results

Search found 36172 results on 1447 pages for 'unicode string'.

Page 76/1447 | < Previous Page | 72 73 74 75 76 77 78 79 80 81 82 83  | Next Page >

  • How does .NET compiler compare two strings?

    - by Pankaj
    string a="I am comparing 2 string"; string b="I am comparing 2 string"; if(a==b) return true; else return false; How does a .NET compiler compare two strings? Does a string work like a struct(int)? string is class so a=b means we are comparing 2 object, but i want to compare 2 values.

    Read the article

  • How to Call my global value in app.config file

    - by deep
    Hai, am using c# and wpf am having my value as a string, i need to call the string value in my app.config file for example in app.config file am having my connection string. the username may vary diff time. am having the user name as a globasl string. i need to call that string in my app.config connection string when application startup????

    Read the article

  • c# create an arbitrary length generic parameter string e.g. ?,?,?

    - by Sky Sanders
    I know I am forgetting to remember how to do this and it is late. I want to, in an elegant manner, build a placeholder list for a munged sql command. Have a command with an arbitrary number of parameters, need to build ?,?,? Did I mention that it was a wet brain fart? this is what came out: Regex.Replace(new string('?', _command.Parameters.Count), @"\?\?", @"\?,\?"); You are welcome to make me feel like more of an idiot if you just remember me what I am forgetting. ;-)

    Read the article

  • Indenting Paragraph With cout

    - by Eric
    Given a string of unknown length, how can you output it using cout so that the entire string displays as an indented block of text on the console? (so that even if the string wraps to a new line, the second line would have the same level of indentation) Example: cout << "This is a short string that isn't indented." << endl; cout << /* Indenting Magic */ << "This is a very long string that will wrap to the next line because it is a very long string that will wrap to the next line..." << endl; And the desired output: This is a short string that isn't indented. This is a very long string that will wrap to the next line because it is a very long string that will wrap to the next line... Edit: The homework assignment I'm working on is complete. The assignment has nothing to do with getting the output to format as in the above example, so I probably shouldn't have included the homework tag. This is just for my own enlightment. I know I could count through the characters in the string, see when I get to the end of a line, then spit out a newline and output -x- number of spaces each time. I'm interested to know if there is a simpler, idiomatic C++ way to accomplish the above.

    Read the article

  • Stuck at being unable to print a substring no more than 4679 characters

    - by Newcoder
    I have a program that does string manipulation on very large strings (around 100K). The first step in my program is to cleanup the input string so that it only contains certain characters. Here is my method for this cleanup: public static String analyzeString (String input) { String output = null; output = input.replaceAll("[-+.^:,]",""); output = output.replaceAll("(\\r|\\n)", ""); output = output.toUpperCase(); output = output.replaceAll("[^XYZ]", ""); return output; } When i print my 'input' string of length 97498, it prints successfully. My output string after cleanup is of length 94788. I can print the size using output.length() but when I try to print this in Eclipse, output is empty and i can see in eclipse output console header. Since this is not my final program, so I ignored this and proceeded to next method that does pattern matching on this 'cleaned-up' string. Here is code for pattern matching: public static List<Integer> getIntervals(String input, String regex) { List<Integer> output = new ArrayList<Integer> (); // Do pattern matching Pattern p1 = Pattern.compile(regex); Matcher m1 = p1.matcher(input); // If match found while (m1.find()) { output.add(m1.start()); output.add(m1.end()); } return output; } Based on this program, i identify the start and end intervals of my pattern match as 12351 and 87314. I tried to print this match as output.substring(12351, 87314) and only get blank output. Numerous hit and trial runs resulted in the conclusion that biggest substring that i can print is of length 4679. If i try 4680, i again get blank input. My confusion is that if i was able to print original string (97498) length, why i couldnt print the cleaned-up string (length 94788) or the substring (length 4679). Is it due to regular expression implementation which may be causing some memory issues and my system is not able to handle that? I have 4GB installed memory.

    Read the article

  • String Vector program exits before input

    - by kylepayne
    So, I have a project that must add, delete, and print the contents of a vector... the problem is that, when run the program exits before I can type in the string to add to the vector. I commented the function that that portion is in. Thanks! #include <iostream> #include <cstdlib> #include <vector> #include <string> using namespace std; void menu(); void addvector(vector<string>& vec); void subvector(vector<string>& vec); void vectorsize(const vector<string>& vec); void printvec(const vector<string>& vec); void printvec_bw(const vector<string>& vec); int main() { vector<string> svector; menu(); return 0; } //functions definitions void menu() { vector<string> svector; int choice = 0; cout << "Thanks for using this program! \n" << "Enter 1 to add a string to the vector \n" << "Enter 2 to remove the last string from the vector \n" << "Enter 3 to print the vector size \n" << "Enter 4 to print the contents of the vector \n" << "Enter 5 ----------------------------------- backwards \n" << "Enter 6 to end the program \n"; cin >> choice; switch(choice) { case 1: addvector(svector); break; case 2: subvector(svector); break; case 3: vectorsize(svector); break; case 4: printvec(svector); break; case 5: printvec_bw(svector); break; case 6: exit(1); default: cout << "not a valid choice \n"; // menu is structured so that all other functions are called from it. } } void addvector(vector<string>& vec) { string line; int i = 0; cout << "Enter the string please \n"; getline(cin, line); // doesn't prompt for input! vec.push_back(line); } void subvector(vector<string>& vec) { vec.pop_back(); return; } void vectorsize(const vector<string>& vec) { if (vec.empty()) { cout << "vector is empty"; } else { cout << vec.size() << endl; } return; } void printvec(const vector<string>& vec) { for(int i = 0; i < vec.size(); i++) { cout << vec[i] << endl; } return; } void printvec_bw(const vector<string>& vec) { for(int i = vec.size(); i > 0; i--) { cout << vec[i] << endl; } return; }

    Read the article

  • null pointer exception comparing two strings in java.

    - by David
    I got this error message and I'm not quite sure whats wrong: Exception in thread "main" java.lang.NullPointerException at Risk.runTeams(Risk.java:384) at Risk.blobRunner(Risk.java:220) at Risk.genRunner(Risk.java:207) at Risk.main(Risk.java:176) Here is the relevant bits of code (i will draw attention to the line numbers within the error message via comments in the code as well as inputs i put into the program while its running where relevant) public class Risk { ... public static void main (String[]arg) { String CPUcolor = CPUcolor () ; genRunner (CPUcolor) ; //line 176 ... } ... public static void genRunner (String CPUcolor) // when this method runs i select 0 and run blob since its my only option. Theres nothing wrong with this method so long as i know, this is only significant because it takes me to blob runner and because another one of our relelvent line numbers apears. { String[] strats = new String[1] ; strats[0] = "0 - Blob" ; int s = chooseStrat (strats) ; if (s == 0) blobRunner (CPUcolor) ; // this is line 207 } ... public static void blobRunner (String CPUcolor) { System.out.println ("blob Runner") ; int turn = 0 ; boolean gameOver = false ; Dice other = new Dice ("other") ; Dice a1 = new Dice ("a1") ; Dice a2 = new Dice ("a2") ; Dice a3 = new Dice ("a3") ; Dice d1 = new Dice ("d1") ; Dice d2 = new Dice ("d2") ; space (5) ; Territory[] board = makeBoard() ; IdiceRoll (other) ; String[] colors = runTeams(CPUcolor) ; //this is line 220 Card[] deck = Card.createDeck () ; System.out.println (StratUtil.canTurnIn (deck)) ; while (gameOver == false) { idler (deck) ; board = assignTerri (board, colors) ; checkBoard (board, colors) ; } } ... public static String[] runTeams (String CPUcolor) { boolean z = false ; String[] a = new String[6] ; while (z == false) { a = assignTeams () ; printOrder (a) ; boolean CPU = false ; for (int i = 0; i<a.length; i++) { if (a[i].equals(CPUcolor)) CPU = true ; //this is line 384 } if (CPU==false) { System.out.println ("ERROR YOU NEED TO INCLUDE THE COLOR OF THE CPU IN THE TURN ORDER") ; runTeams (CPUcolor) ; } System.out.println ("is this turn order correct? (Y/N)") ; String s = getIns () ; while (!((s.equals ("y")) || (s.equals ("Y")) || (s.equals ("n")) || (s.equals ("N")))) { System.out.println ("try again") ; s = getIns () ; } if (s.equals ("y") || s.equals ("Y") ) z = true ; } return a ; } ... } // This } closes the class The reason i don't think i should be getting a Null:pointerException is because in this line: a[i].equals(CPUcolor) a at index i holds a string and CPUcolor is a string. Both at this point definatly have a value neither is null. Can anyone please tell me whats going wrong?

    Read the article

  • Ruby on Rails: how to render a string as HTML?

    - by Tim
    I have @str = "<b>Hi</b>" and in my erb view: <%= @str > What will display on the page is: <b>Hi</b> when what I really want is Hi. What's the ruby way to "interpret" a string as HTML markup? Edit: the case where @str = "<span class=\"classname\">hello</span>" If in my view I do <%raw @str %> The HTML source code is <span class=\"classname\">hello</span where what I really want is <span class="classname">hello</span> (without the backslashes that were escaping the double quotes). What's the best way to "unescape" those double quotes?

    Read the article

  • Is there an easy way to concatenate several lines of text into a string without constantly appending

    - by Marshmellow1328
    So I essentially need to do this: String text = "line1\n"; text += "line2\n"; text += "line3\n"; useString( text ); There is more involved, but that's the basic idea. Is there anything out there that might let me do something more along the lines of this though? DesiredStringThinger text = new DesiredStringThinger(); text.append( "line1" ); text.append( "line2" ); text.append( "line3" ); useString( text.toString() ); Obviously, it does not need to work exactly like that, but I think I get the basic point across. There is always the option of writing a loop which processes the text myself, but it would be nice if there is a standard Java class out there that already does something like this rather than me needing to carry a class around between applications just so I can do something so trivial. Thanks!

    Read the article

  • Prolog .. Can i convert from a list of chars to a string or term in Prolog !!

    - by AhmadAssaf
    i use read_line_to_codes(Stream,Line) to read a line from a file .. first is there any way to read a line and assign it to a term in prolog ?? if not i managed to read a line and put it in this char list .. now this char list contains spaces .. which is bad .. so i want to convert it to a term or a string in prolog so that i can process it easier .. spaces cannot be atoms so thats a problem .. i appreciate the help !!

    Read the article

  • Using C# to detect whether a filename character is considered international

    - by Morten Mertner
    I've written a small console application (source below) to locate and optionally rename files containing international characters, as they are a source of constant pain with most source control systems (some background on this below). The code I'm using has a simple dictionary with characters to look for and replace (and nukes every other character that uses more than one byte of storage), but it feels very hackish. What's the right way to (a) find out whether a character is international? and (b) what the best ASCII substitution character would be? Let me provide some background information on why this is needed. It so happens that the danish Å character has two different encodings in UTF-8, both representing the same symbol. These are known as NFC and NFD encodings. Windows and Linux will create NFC encoding by default but respect whatever encoding it is given. Mac will convert all names (when saving to a HFS+ partition) to NFD and therefore returns a different byte stream for the name of a file created on Windows. This effectively breaks Subversion, Git and lots of other utilities that don't care to properly handle this scenario. I'm currently evaluating Mercurial, which turns out to be even worse at handling international characters.. being fairly tired of these problems, either source control or the international character would have to go, and so here we are. My current implementation: public class Checker { private Dictionary<char, string> internationals = new Dictionary<char, string>(); private List<char> keep = new List<char>(); private List<char> seen = new List<char>(); public Checker() { internationals.Add( 'æ', "ae" ); internationals.Add( 'ø', "oe" ); internationals.Add( 'å', "aa" ); internationals.Add( 'Æ', "Ae" ); internationals.Add( 'Ø', "Oe" ); internationals.Add( 'Å', "Aa" ); internationals.Add( 'ö', "o" ); internationals.Add( 'ü', "u" ); internationals.Add( 'ä', "a" ); internationals.Add( 'é', "e" ); internationals.Add( 'è', "e" ); internationals.Add( 'ê', "e" ); internationals.Add( '¦', "" ); internationals.Add( 'Ã', "" ); internationals.Add( '©', "" ); internationals.Add( ' ', "" ); internationals.Add( '§', "" ); internationals.Add( '¡', "" ); internationals.Add( '³', "" ); internationals.Add( '­', "" ); internationals.Add( 'º', "" ); internationals.Add( '«', "-" ); internationals.Add( '»', "-" ); internationals.Add( '´', "'" ); internationals.Add( '`', "'" ); internationals.Add( '"', "'" ); internationals.Add( Encoding.UTF8.GetString( new byte[] { 226, 128, 147 } )[ 0 ], "-" ); internationals.Add( Encoding.UTF8.GetString( new byte[] { 226, 128, 148 } )[ 0 ], "-" ); internationals.Add( Encoding.UTF8.GetString( new byte[] { 226, 128, 153 } )[ 0 ], "'" ); internationals.Add( Encoding.UTF8.GetString( new byte[] { 226, 128, 166 } )[ 0 ], "." ); keep.Add( '-' ); keep.Add( '=' ); keep.Add( '\'' ); keep.Add( '.' ); } public bool IsInternationalCharacter( char c ) { var s = c.ToString(); byte[] bytes = Encoding.UTF8.GetBytes( s ); if( bytes.Length > 1 && ! internationals.ContainsKey( c ) && ! seen.Contains( c ) ) { Console.WriteLine( "X '{0}' ({1})", c, string.Join( ",", bytes ) ); seen.Add( c ); if( ! keep.Contains( c ) ) { internationals[ c ] = ""; } } return internationals.ContainsKey( c ); } public bool HasInternationalCharactersInName( string name, out string safeName ) { StringBuilder sb = new StringBuilder(); Array.ForEach( name.ToCharArray(), c => sb.Append( IsInternationalCharacter( c ) ? internationals[ c ] : c.ToString() ) ); int length = sb.Length; sb.Replace( " ", " " ); while( sb.Length != length ) { sb.Replace( " ", " " ); } safeName = sb.ToString().Trim(); string namePart = Path.GetFileNameWithoutExtension( safeName ); if( namePart.EndsWith( "." ) ) safeName = namePart.Substring( 0, namePart.Length - 1 ) + Path.GetExtension( safeName ); return name != safeName; } } And this would be invoked like this: FileInfo file = new File( "Århus.txt" ); string safeName; if( checker.HasInternationalCharactersInName( file.Name, out safeName ) ) { // rename file }

    Read the article

  • [0-9a-zA-Z]* string expressed with primes or prime-factorization-style way to break it into parts?

    - by HH
    Suppose a string consists of numbers and alphabets. You want to break it into parts, an analogy is primes' factorization, but how can you do similar thing with strings [0-9a-zA-Z]* or even with arbitrary strings? I could express it in alphabets and such things with octal values and then prime-factorize it but then I need to keep track of places where I had the non-numbers things. Is there some simple way to do it? I am looking for simple succinct solutions and don't want too much side-effects. [Update] mvds has the correct idea, to change the base, how would you implement it?

    Read the article

  • Serializing JSON string to object

    - by user1476075
    I am trying to parse through a JSON string and convert it to the following POJO: package apicall; //POJO representation of OAuthAccessToken public class OAuthAccessToken { private String tokenType; private String tokenValue; public OAuthAccessToken(String tokenType,String tokenValue) { this.tokenType=tokenType; this.tokenValue=tokenValue; } public String toString() { return "tokenType="+tokenType+"\ntokenValue="+tokenValue; } public String getTokenValue() { return tokenValue; } public String getTokenType() { return tokenType; } } In order to do this I have written the following code: Gson gson=new Gson(); String responseJSONString="{\"access_token\" : \"2YotnFZFEjr1zCsicMWpAA\",\"token_type\" : \"bearer\"}"; OAuthAccessToken token=gson.fromJson(responseJSONString, OAuthAccessToken.class); System.out.println(token); When I run the code, I get the following output: tokenType=null tokenValue=null Instead of tokenType=bearer tokenValue=2YotnFZFEjr1zCsicMWpAA I dont understand if there's anything I've done wrong. Please help.

    Read the article

  • How to search for a string including spaces in Objective C?

    - by AlexCu
    I have a real basic command-line program, in Objective-C, that searches for user inputed information. Unfourtunately, the code will only read the first word in series of words that the user enters. For example, if the user enters in "Apples are great", only "Apples" is kept (and hence searched later on), excluding the "are great" part of the sentence. Here's what I have so far: char enteredQuery [128]; // array 'name' to hold the scanf string NSString *searchQuery; // ending NSString to hold and compare the user inputed data NSLog(@"Enter search query:"); scanf("%s", enteredQuery); //will read the next line searchQuery = [NSString stringWithCString: enteredQuery encoding: NSASCIIStringEncoding]; //converts scanf data into a NSString type I know it's got to do with me using scanf or the character-encoder conversion, but I can't seem to figure it out. Any help in solving the problem is very appreciated! Thanks.

    Read the article

  • Can we Initialize dynamic string array .

    - by SunilRai86
    is there any way to Initialize dynamic string array . public class CXmlFileHook { string vAppname; string vClassname; string vIdmark; string vExecname; string [] vApiName; string vCtor; public CXmlFileHook() { this.vAppname = "Not Set"; this.vIdmark = "Not Set"; this.vClassname = "Not Set"; this.vExecname = "Not Set"; this.vApiName = new string[9] { "Not Set", "Not Set", "Not Set", "Not Set", "Not Set", "Not Set", "Not Set", "Not Set" ,"Not Set"}; this.vCtor = "CXmlFileHook()"; } now i want the size of the string should increases dynamically and according to size it initializes it self is it possible????

    Read the article

  • Java, How to Instance HttpCookie from a String, any convenient ways?

    - by user435657
    Hi all, I have got a cookie string from HTTP response header like the following line: name=value; path=/; domain=.g.cn; expire=... I can parse the above line to key-value pairs, and, also it's easy to set the name and value to HttpCookie instance as this pair comes the first. But how to set the other pairs since I don't know which set-method corresponds to the name of the next name-value pair. Traverse all possible keys a cookie may contian and call the matched set-method, like below snippet? if (key.equalsIgnoreCase("path")) cookie.setPath(value); else if (key.equalsIgnoreCase("domain")) cookie.setDomain(value); That's foolish, any convenient ways? Thanks in advance.

    Read the article

  • Regex to split a string (in Java) so that spaces are preserved?

    - by david
    I need to split a string (in Java) into individual words ... but I need to preserve spaces. An example of the text I need to split is something like this: ABC . . . . DEF . . . . GHI I need to see "ABC", " . . . .", "DEF", ". . . .", and "GHI". Obviously splitting on the space character \s isn't going to work, as all the spaces get swallowed up as one space. Any suggestions? Thanks

    Read the article

  • what does this string.format piece of code do?

    - by jbkkd
    I have this piece of code in c#: private static void _constructRow(SqlDataReader reader, system.IO.StreamWriter stwr, bool getColumnName) { for (int i = 0; i < reader.FieldCount; i++) stwr.Writeline(String.Format("<td>{0}</td"), getColumnName ? reader.GetName(i) : reader.GetValue(i).ToString())); } I'm trying to understand what the part that start with "getColumnName ?" and ends with ".ToString()" does. I understood that it is a system.object type, but I have no idea what it specifically does or how it works. I want that because of this: "reader" had multiple rows in it, and I want to writeline only specific rows. If anyone can help me on either of those, I'd be grateful.

    Read the article

  • How to get a variable name as a string in Python?

    - by e-satis
    I would like to be able to get the name of a variable as a string but I don't know if Python has that much introspection capabilities. Something like: >>> print(my_var.__name__) 'my_var' I want to do that because I have a bunch of vars I'd like to turn into a dictionary like : bar=True foo=False >>> my_dict=dict(bar=bar, foo=foo) >>> print mydict >>> print my_dict {'foo': False, 'bar': True} But I'd like something more automatic than that. Python have locals() and vars(), so I guess there is a way.

    Read the article

  • How could I insert a string into the response stream anywhere I want?

    - by DM
    There may be an easy way to do this but I can't see it... I created a simple Http Module that starts a timer on the PreRequestHandler and stops the timer on the PostRequestHandler to calculate the time it took the page to load. I then create some simple html and write my results to Response.Write. Since I'm doing this in the PostRequestHandler it's adding my results after the </html> tag. That's fine for testing but I need in a scenario where the page needs to validate. I can't seem to figure out how I could manipulate the Response object to insert my results before the </body> tag. Response.Write and Response.Output.Write don't have that flexibility and I couldn't see a way to work with the Response as a string. Am I missing something easy?

    Read the article

  • How does one find a '.' in a string object in Object-C

    - by NaZer
    I am working on getting a simple calculator working as part of my adventure to learning Object-C and iOS development. In Object-C using NSString, how does one look for a period in a string? Based on the comments this is what I got so far. NSString * tmp = [display text]; NSLog(@"%@", tmp); // Shows the number on the display correctly int x = [tmp rangeOfString:@"."].location; NSLog(@"%i", x); // Shows some random signed number if (x < 0) { [display setText:[[display text] stringByAppendingFormat:@"."]]; } It is still not working :(

    Read the article

  • Referencing an XML string in an XML Array (Android)

    - by jax
    in arrays.xml <string-array name="my_items"> <item>My item 1</item> <item>My item 2</item> <item>My item 3</item> </string-array> in strings.xml <resources> <string name="item1">My item 1</string> <string name="item2">My item 2</string> <string name="item3">My item 3</string> </resources> I would like to reference the string in the array "My item 1" from strings.xml. How do I do that?

    Read the article

  • foreach statement (get string values)

    - by nhoyti
    Can someone please help me out? My code for splitting the strings is working however, i still need to use the splitted string my page. How can i achieve this? Here's my current code private void SplitStrings() { List<string> listvalues = new List<string>(); listvalues = (List<string>)Session["mylist"]; string[] strvalues = listvalues.ToArray(); if (listvalues != null) { foreach (string strElement in listvalues) { string[] prods = strElement.ToString().Split("|".ToCharArray()); string prodName = prods[0].ToString(); Response.Write(prodName); } } } link text how can i replace the response.write with any label or literal? when i tried to use a literal on the code it displays one single string not all of the strings that's been splitted. any ideas?

    Read the article

< Previous Page | 72 73 74 75 76 77 78 79 80 81 82 83  | Next Page >