Search Results

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

Page 99/1447 | < Previous Page | 95 96 97 98 99 100 101 102 103 104 105 106  | Next Page >

  • C++ class is not recognizing string data type

    - by reallythecrash
    I'm working on a program from my C++ textbook, and this this the first time I've really run into trouble. I just can't seem to see what is wrong here. Visual Studio is telling me Error: identifier "string" is undefined. I separated the program into three files. A header file for the class specification, a .cpp file for the class implementation and the main program file. These are the instructions from my book: Write a class named Car that has the following member variables: year. An int that holds the car's model year. make. A string that holds the make of the car. speed. An int that holds the car's current speed. In addition, the class should have the following member functions. Constructor. The constructor should accept the car's year and make as arguments and assign these values to the object's year and make member variables. The constructor should initialize the speed member variable to 0. Accessors. Appropriate accessor functions should be created to allow values to be retrieved from an object's year, make and speed member variables. There are more instructions, but they are not necessary to get this part to work. Here is my source code: // File Car.h -- Car class specification file #ifndef CAR_H #define CAR_H class Car { private: int year; string make; int speed; public: Car(int, string); int getYear(); string getMake(); int getSpeed(); }; #endif // File Car.cpp -- Car class function implementation file #include "Car.h" // Default Constructor Car::Car(int inputYear, string inputMake) { year = inputYear; make = inputMake; speed = 0; } // Accessors int Car::getYear() { return year; } string Car::getMake() { return make; } int Car::getSpeed() { return speed; } // Main program #include <iostream> #include <string> #include "Car.h" using namespace std; int main() { } I haven't written anything in the main program yet, because I can't get the class to compile. I've only linked the header file to the main program. Thanks in advance to all who take the time to investigate this problem for me.

    Read the article

  • Look up or insert new element to string list in Haskell

    - by nightscream
    So I want to have a function that takes a String and a list as an argument, and checks if that element is already on the list, if it is, returns the same list, if it isnt, adds it to the list and returns it, 'im a begginer with haskell so heres what I have tried with no sucess: check:: String ->[String] ->[String] check x [] = []++[x] check x (y:xs) | x==y = (y:xs) | otherwise = check x xs Can someone point me the way ? thks

    Read the article

  • Linq: convert string to int array

    - by Oops
    I have a function (tointarray) to convert a string into an array of ints, but I am not very satisfied with it. it does the job but there must be a more elegant way to do this, perhaps Linq could help here. unfortunately I am not very good in Linq. do you guys know a better way? my function: { string s1 = "1;2;3;4;5;6;7;8;9;10;11;12"; int[] ia = tointarray(s1, ';'); } int[] tointarray(string value, char sep) { string[] sa = value.Split(sep); int[] ia = new int[sa.Length]; for (int i = 0; i < ia.Length; ++i) { int j; string s = sa[i]; if (int.TryParse(s, out j)) { ia[i] = j; } } return ia; }

    Read the article

  • C# Modify Connection String that exists inside a library

    - by LnDCobra
    I have a Class Library, which inside just has a DataSet (MySQL connector) and a Connector class. I use this class in multiple projects to connect to the database, and I always had the password embedded in the connection string but now I need to be able to modify this string(for security purposes) so I can have the user connect using their own account. How can I modify this connection string. I have tried the following Properties.Settings.Default.DataBaseConnectionString = "String"; But it seems that the connection string is readonly becase it doesn't appear to have a setter value. I also tried the following with no luck Properties.Settings.Default.DatabaseConnectionString.Insert( Properties.Settings.Default.DatabaseConnectionConnectionString.Length - 1, "Password=dbpassword;");

    Read the article

  • HTML encode UTF-8 string gets mangled into latin1

    - by Ken Mayer
    I'm parsing my nginx logs, and I want to discover some details from the HTTP_REFERER string, for example, the query string used to find the web site. One user typed in "México" which gets encoded in the log as "query=M%E9xico". Passing this through Rack::Utils.parse_query('query=M%E9xico') you get a hash, {"query" = "M?xico"} When you to stuff "M?exico" into Postgres (but not the more forgiving SQLite), it pukes because the string isn't proper UTF-8. Looking at http://rack.rubyforge.org/doc/Rack/Utils.html#M000324, unescape is packing a hex string. How can I convert the string back to UTF-8, or can I get parse_query to return UTF-8 in the first place.

    Read the article

  • Binary to strings as binary? C #/.NET

    - by acidzombie24
    Redis keys are binary safe. I'd like to mess around and put binary into redis using C#. My client of choice doesn't support writing binary keys it uses keys and it make sense. However i am just fooling around so tell me how i can do this. How do i convert a raw byte[] into a string? At first i was thinking about converting a byte[] to a utf8 string however unicode has some checks to see if its valid or not. So raw binary should fail. Actually i tried it out. Instead of failing i got a strange result. My main question is how do i convert a raw byte[] to the equivalent string? My unimportant question is why did i get a 512 byte string instead of an exception saying this is not a valid UTF8 string? code var rainbow = new byte[256]; for (int i = 0; i < 256; i++) { rainbow[i] = (byte)i; } var sz = Encoding.UTF8.GetString(rainbow); var szarr = Encoding.UTF8.GetBytes(sz); Console.WriteLine("{0} {1} {2}", ByteArraysEqual(szarr, rainbow), szarr.Length, rainbow.Length); Output False 512 256

    Read the article

  • "Simple" Text replace function

    - by YourMomzThaBomb
    I have a string which is basically a list of "words" delimited by commas. These "words" can be pretty much any character e.g. "Bart Simpson, Ex-girlfriend, dude, radical" I'm trying to use javascript, jQuery, whatever i can to replace a word based on a search string with nothing (in essence, removing the word from the list). For example, the function is defined as such: function removeWord(myString, wordToReplace) {...}; So, passing the string listed above as myString and passing "dude" as wordToReplace would return the string "Bart Simpson, Ex-girlfriend, radical" Here's the line of code I was tinkering around with...please help me figure out what's wrong with it or some alternative (better) solution:$myString.val($myString.val().replace(/wordToReplace\, /, ""));

    Read the article

  • c# reading integer fields from database, returning empty string when reading integer type field

    - by arnoldino
    what is wrong with this code? field="id"; table="MInvMonth"; condition="machine_id=37"; public static String getConditionedField(String field, String table, String condition) try { if (cmd == null) getConnection(); cmd.CommandText = "Select " + field + " from " + table + " where " + condition; SQLiteDataReader reader = cmd.ExecuteReader(); if (reader.HasRows==true) { reader.Read(); string s = reader[0].ToString(); // return first element reader.Close(); return s; } reader.Close(); return null; } catch (Exception e) { MessageBox.Show("Caught exception: " + e.Message+"|"+cmd.CommandText); return null; } I checked the sql statement, it turns the right value. why can't I read it? the returnvalue is "".

    Read the article

  • What is the complexity of the below code with respect to memory ?

    - by Cshah
    Hi, I read about Big-O Notation from here and had few questions on calculating the complexity.So for the below code i have calculated the complexity. need your inputs for the same. private void reverse(String strToRevers) { if(strToRevers.length() == 0) { return ; } else { reverse(strToRevers.substring(1)); System.out.print(strToRevers.charAt(0)); } } If the memory factor is considered then the complexity of above code for a string of n characters is O(n^2). The explanation is for a string that consists of n characters, the below function would be called recursively n-1 times and each function call creates a string of single character(stringToReverse.charAT(0)). Hence it is n*(n-1)*2 which translates to o(n^2). Let me know if this is right ?

    Read the article

  • Convert CString array to System::String

    - by Anu
    Hi, I want to convert CString array to managed code ot send it to C#. For normal CString i did like this, CString menu = "MENU"; String ^ msg = gcnew String(menu); Globals1::gwtoolbar->Add(msg); But now i want to send array of string.i dont know how to do for CString array. When i gave like this it shows error CString menu[10]; String[] ^ msg = gcnew String(menu); How can i convert it?

    Read the article

  • How do I concatenate strings in Objective-C?

    - by Typeoneerror
    Are there any shortcuts to (stringByAppendingString:) string concatenation in Objective-C or shortcuts for working with NSString or other objects in general? e.g. I'd like to make this: NSString *myString = @"This"; NSString *test = [myString stringByAppendingString:@" is just a test"]; something more like this: string myString = "This"; string test = myString + " is just a test";

    Read the article

  • Escaping Strings in JavaScript

    - by Steve Harrison
    Hello, Does JavaScript have a built-in function like PHP's addslashes (or addcslashes) function to add backslashes to characters that need escaping in a string? For example, this: This is a demo string with 'single-quotes' and "double-quotes". ...would become: This is a demo string with \'single-quotes\' and \"double-quotes\". Thanks, Steve

    Read the article

  • NHibernate custom connection string configuration

    - by user177883
    I have a c# library project, that i configured using nhibernate, and I like people to be able to import this project and use the project. This project has FrontController that does all the work. I have a connection string in hibernate config file and in app.config file of another project. it would be nice for anyone to be able to set the connection string into this library project and use it. such as through a method which will take the connectiong string as parameter. or when creating a new instance of FrontController to pass the connection string to constructor. or if you have a better idea. How to do this? I d like this class library to use the same database of the project that s imported. How to set hibernate connection string programatically? same idea for log4net.

    Read the article

  • Silverlight clipping a string on mac

    - by Haris
    hello, I am facing a very strange issue in my silverlight app on all browsers on mac but it is working perfectly in all windows browsers. in my silverlight app there is a scenario in which I create a very long text string and then pass it to a wcf service which then saves the string in a text file server. the issue is that in mac every time string is clipped after about same location. but it is working perfectly fine in all browsers on windows. btw in silverlight I am using string builder to build the string.

    Read the article

  • Is there any legitimate use for bare strings in PHP?

    - by Robert
    This question got me thinking about bare strings. When PHP sees a string that's not enclosed in quotes, it first checks to see if it's a constant. If not, it just assumes it's a string and goes on anyway. So for example if I have echo $foo[bar]; If there's a constant called bar it uses that for the array key, but if not then it treats bar as a bare string, so it behaves just like echo $foo["bar"]; This can cause all kinds of problems if at some future date a constant is added with the same name. My question is, is there any situation in which it actually makes sense to use a bare string?

    Read the article

  • Dynamic Connection Strings for Strongly Typed DataSet in a Class Library using App.Config

    - by Luc
    This is my first question on StackOverflow.com and I'm not sure if this is the correct way to do this. I found a similar question titled: Modifying the Data Source for the Strongly Typed Dataset Connection String. However, the answer provided is not working for me. I'm not able to comment on it because I don't have enough "reputation points" (again, I just signed up), and I didn't want to provide an "answer", because I don't know the correct answer. My problem is that I need to be able to modify the connection string inside the generated myproject.dll.config file, but doing so has no effect for me at all. My library still uses the default connection string that was setup at design time. I've tried everything I know to try, but still no luck. I've tried working around the issue using multiple different approaches, but still the problem persists. I can't find any help on the internet with my specific problem either. It would be great if somebody could shed some light as to why my modified config file isn't being read. Useful information: I'm using a Strongly Typed DataSet I don't know the actual connection string at design time. The app.config doesn't allow me to specify a 'User' scoped connection string. I'm tied to a class library (no Windows Forms) Thank you for any help! Luc

    Read the article

  • Retrieving part of a string using jQuery / JavaScript

    - by ILMV
    I know how I would achieve this using PHP, but with jQuery / JavaScript I'm not sure how to, here's the string I'm dealing with (It's the name attribute from a input element): Field[0][some_random_text] I want to retrieve the value some_random_text and slap it in a variable, I guess I would usually use regex to accomplish this task but not sure how this is done in JavaScript. Here are some characteristics of this name attribute. It will always be in this format string[string][string] Each of the strings can be any length How would I get the some_random_text string? I'd like to stick to the standard set of functions if possible.

    Read the article

  • strod() and sprintf() inconsistency under GCC and MSVC

    - by Dmitry Sapelnikov
    I'm working on a cross-platform app for Windows and Mac OS X, and I have a problem with two standard C library functions: strtod() (string-to-double conversion) ? sprintf (when used for outputting double-precision floating point numbers) -- their GCC and MSVC versions return different results. I'm looking for a well-tested cross-platform open-source implementation of those functions, or just for a pair of functions that would correctly and consistently convert double to string and back. I've already tried the clib GCC implementation, but the code is too long and too dependent on other source files, so I expect the adaptation to be difficult. What implementations of string-to-double and double-to-string functions would you recommend?

    Read the article

  • ruby write newline character to file but do not interpret as a true newline

    - by thomas
    I am trying to write a ruby string to a file in such a way that any newline characters embedded in the string remain embedded. This is being written out to a file which will then be processed by another tool. An example is below. I want this: 1 [label="this is a\ntest"] \n (second \n is a true newline) I have tried this: string = '1 [label="this is a\ntest"]' + "\n" Any thoughts?

    Read the article

  • How to create a Java String from the contents of a file

    - by Oscar Reyes
    I've been using this idiom for some time now. And it seems to be the most wide spread at least in the sites I've visited. Does anyone have a better/different way to read a file into a string in Java. Thanks private String readFile( String file ) throws IOException { BufferedReader reader = new BufferedReader( new FileReader (file)); String line = null; StringBuilder stringBuilder = new StringBuilder(); String ls = System.getProperty("line.separator"); while( ( line = reader.readLine() ) != null ) { stringBuilder.append( line ); stringBuilder.append( ls ); } return stringBuilder.toString(); }

    Read the article

  • java reading numbers, interpreting as octal, want interpreted as string

    - by user331401
    hello, i am having an issue, where java is reading an array list from a YAML file of numbers, or strings, and it is interpreting the numbers as octal if it has a leading 0, and no 8-9 digit. is there a way to force java to read the yaml field as a string? code: ArrayList recordrarray = (ArrayList) sect.get("recordnum"); if (recordrarray != null) { recno = join (recordrarray, " "); } HAVE ALSO TRIED: Iterator<String> iter = recordrarray.iterator(); if (iter.hasNext()) recno = " " +String.valueOf(iter.next()); System.out.println(" this recnum:" + recno); while (iter.hasNext()){ recno += ""+String.valueOf(iter.next())); System.out.println(" done recnum:" + String.valueOf(iter.next())); } the input is such: 061456 changes to 25390 061506 changes to 25414 061559 - FINE it took a while to figure out what it was doing, and apparently this is a common issue for java, ideas? thanks

    Read the article

  • Black berry: Getting NULL string for exception message.

    - by vikram deshpande
    I used code given but I am getting "IOCancelledException" and "IOException". And IOCancelledException.getMessage() / IOException.getMessage() giving null string, it does not give error message. Please help me understaing reason. class SMSThread extends Thread { Thread myThread; MessageConnection msgConn; String message; String mobilenumber; public SMSThread( String textMsg, String mobileNumber ) { message = textMsg; mobilenumber = mobileNumber; } public void run() { try { msgConn = (MessageConnection) Connector.open("sms://+"+ mobilenumber); TextMessage text = (TextMessage) msgConn.newMessage(MessageConnection.TEXT_MESSAGE); text.setPayloadText(message); msgConn.send(text); msgConn.close(); }catch (IOCancelledException ioce){ System.out.println("IOCancelledException: " + ioce.getMessage()); }catch(IOException ioe){ System.out.println("IOException: " + ioe.getMessage()); } catch (Exception e) { System.out.println("Exception: " + e); } } }

    Read the article

< Previous Page | 95 96 97 98 99 100 101 102 103 104 105 106  | Next Page >