Search Results

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

Page 51/1447 | < Previous Page | 47 48 49 50 51 52 53 54 55 56 57 58  | Next Page >

  • How to evaluate the string in ruby if the string contains ruby command?

    - by Arun
    In my case, I was storing the sql query in my database as text. I am showing you one record which is present in my database Query.all :id => 1, :sql => "select * from user where id = #{params[:id]}" str = Query.first Now 'str' has value "select * from user where id = #{params[:id]}" Here, I want to parsed the string like If my params[:id] is 1 then "select * from user where id = 1" I used eval(str). Is this correct?

    Read the article

  • add space to every word's end in a string in C

    - by hlx98007
    Here I have a string: *line = "123 567 890 "; with 2 spaces at the end. I wish to add those 2 spaces to 3's end and 7's end to make it like this: "123 567 890" I was trying to achieve the following steps: parse the string into words by words list (array of strings). From upstream function I will get values of variables word_count, *line and remain. concatenate them with a space at the end. add space distributively, with left to right priority, so when a fair division cannot be done, the second to last word's end will have (no. of spaces) spaces, the previous ones will get (spaces + 1) spaces. concatenate everything together to make it a new *line. Here is a part of my faulty code: int add_space(char *line, int remain, int word_count) { if (remain == 0.0) return 0; // Don't need to operate. int ret; char arr[word_count][line_width]; memset(arr, 0, word_count * line_width * sizeof(char)); char *blank = calloc(line_width, sizeof(char)); if (blank == NULL) { fprintf(stderr, "calloc for arr error!\n"); return -1; } for (int i = 0; i < word_count; i++) { ret = sscanf(line, "%s", arr[i]); // gdb shows somehow it won't read in. if (ret != 1) { fprintf(stderr, "Error occured!\n"); return -1; } arr[i] = strcat(arr[i], " "); // won't compile. } size_t spaces = remain / (word_count * 1.0); memset(blank, ' ', spaces + 1); for (int i = 0; i < word_count - 1; i++) { arr[0] = strcat(arr[i], blank); // won't compile. } memset(blank, ' ', spaces); arr[word_count-1] = strcat(arr[word_count-1], blank); for (int i = 1; i < word_count; i++) { arr[0] = strcat(arr[0], arr[i]); } free(blank); return 0; } It is not working, could you help me find the parts that do not work and fix them please? Thank you guys.

    Read the article

  • Write string to fixed-length byte array in C#

    - by toasteroven
    somehow couldn't find this with a google search, but I feel like it has to be simple...I need to convert a string to a fixed-length byte array, e.g. write "asdf" to a byte[20] array. the data is being sent over the network to a c++ app that expects a fixed-length field, and it works fine if I use a BinaryWriter and write the characters one by one, and pad it by writing '\0' an appropriate number of times. is there a more appropriate way to do this?

    Read the article

  • Inserting "£" in a string to a text file

    - by Harry
    iPhone Application writes data to a text file, saves it on the Documnets folder. Great that works If I place "£" in the string, or use [currencyStyle stringFromNumber] the text file will not be created. The "£" and the [currencyStyle stringFromNumber] works if the information is printed to a "New View" page on the simulator, pound and all Can someone please explain what's happening?

    Read the article

  • standard c library for escaping a string.

    - by rampion
    Is there a standard C library function to escape C-strings? For example, if I had the C string: char example[] = "first line\nsecond line: \"inner quotes\""; And I wanted to print "first line\nsecond line: \"inner quotes\"" Is there a library function that will do that transformation for me? Rolling my own just seems a little silly. Bonus points if I can give it a length to escape (so it stops before or beyond the \0).

    Read the article

  • C#: Loop through substring patterns in a string

    - by ilann
    my pattern is the following: {(code)} where code is a number (up to 6 digits), or 2 letter followed by a number. For example: {(45367)} {(265367)} {(EF127012)} I want to find all occurrences in a long string, I can't just use pure regex , because I need to preform some action when i find a match (like logging the position and the type of the match).

    Read the article

  • A better javascript to string function?

    - by Jeff
    Before I go and create this myself, I thought I'd see if anyone knows a library that does this. I'm looking for a function that will take something in Javascript, be it an array, an associative array, a number, or even a string, and convert it to something that looks like it. For example: toString([1,2,3]) === '[1, 2, 3]' toString([[1,2], [2,4], [3,6]]) === '[[1,2], [2,4], [3,6]]' toString(23) === '23' toString('hello world') === 'hello world' toString({'one': 1, 'two': 2, 'three': 3}) === "{'one': 1, 'two': 2, 'three': 3}"

    Read the article

  • What's the easiest way to assign a string returned from the server to a javascript string?

    - by powerboy
    The following does not work: var js_str= '<?php echo $str_from_server; ?>'; The problem is that, $str_from_server can contain any characters. If it contains single quotes or line breaks or others, the above code will break. And I do not have access to the server-side code. What's the easiest way to "escape" the contents of $str_from_server into a javascript string, and then it can be restored later?

    Read the article

  • Won`'t read Unicode characters over NFS mount ?

    - by Julz
    Hello, I'm getting this strange issue when trying to play mp3's containing unicode characters ( accents ) over an NFS on OSX, it's all good over AFP, but I'm setup with NFS because it's a linux server on the other end . This is my disk utility setup : nfs://192.168.1.112/Music advanced mount parameters : -P , nolocks nosuid The strange thing is that I can see those files in the finder ( with the accents .. ) but I cant play them !! So Im wondering if it's an unicode issue, since I can see the files properly or a permission issue since I can't play them, but them it wouldn`t make sense that I can't play ONLY the files containing accents .. help ?? Thanks

    Read the article

  • Font problems after changing non-Unicode locale to Japanese

    - by Kawa
    I recently set my system locale for non-Unicode programs to Japanese and switched it back to American English shortly afterwards. Now, just about all my non-Unicode programs use a larger dialog font without any anti-aliasing instead of Segoe UI 9, as if running on a Japanese locale. One in particular has them switched, using Segoe UI when running on a Japanese locale (be it AppLocale or system) and the Japanese font on American English! Reinstalling that particular program, as a Google search suggested, didn't do anything but reset the toolbar positions. Using Windows 7 Home Premium, and quite confused by all this.

    Read the article

  • Unrealscript splitting a string

    - by burntsugar
    Note, this is repost from stackoverflow - I have only just discovered this site :) I need to split a string in Unrealscript, in the same way that Java's split function works. For instance - return the string "foo" as an array of char. I have tried to use the SplitString function: array SplitString( string Source, optional string Delimiter=",", optional bool bCullEmpty ) Wrapper for splitting a string into an array of strings using a single expression. as found at http://udn.epicgames.com/Three/UnrealScriptFunctions.html but it returns the entire String. simulated function wordDraw() { local String inputString; inputString = "trolls"; local string whatwillitbe; local int b; local int x; local array<String> letterArray; letterArray = SplitString(inputString,, false); for (x = 0; x < letterArray.Length; x++) { whatwillitbe = letterArray[x]; `log('it will be '@whatwillitbe); b = letterarray.Length; `log('letterarray length is '@b); `log('letter number '@x); } } Output is: b returns: 1 whatwillitbe returns: trolls However I would like b to return 6 and whatwillitbe to return each character individually. I have had a few answers proposed, however, I would still like to properly understand how the SplitString function works. For instance, if the Delimiter parameter is optional, what does the function use as a delimiter by default?

    Read the article

  • PyGTK/Quickly Add string to ListStore

    - by AllRadioisDead
    I'm trying to build an application that will prompt the user for a string, and then add that string to a Scrolling Listview object using quickly and PyGTK. I've been following this tutorial: http://developer.ubuntu.com/resources/app-developer-cookbook/multimedia/creating-a-simple-media-player/ When I hit the add button, the prompt comes up properly and I'm able to enter the string. The column appears correctly but the list ends up being blank. What am I doing wrong? import gettext from gettext import gettext as _ gettext.textdomain('spiderweb') from gi.repository import Gtk # pylint: disable=E0611 import logging logger = logging.getLogger('spiderweb') from spiderweb_lib import Window from spiderweb.AboutSpiderwebDialog import AboutSpiderwebDialog from spiderweb.PreferencesSpiderwebDialog import PreferencesSpiderwebDialog from quickly import prompts from quickly.widgets.dictionary_grid import DictionaryGrid import os # See spiderweb_lib.Window.py for more details about how this class works class SpiderwebWindow(Window): __gtype_name__ = "SpiderwebWindow" def finish_initializing(self, builder): # pylint: disable=E1002 """Set up the main window""" super(SpiderwebWindow, self).finish_initializing(builder) self.AboutDialog = AboutSpiderwebDialog self.PreferencesDialog = PreferencesSpiderwebDialog # Code for other initialization actions should be added here. self.supported_web_formats = [".net",".html", ".com"] def on_addbutton_clicked(self, widget, data=None): #let the user choose a path with the directory chooser response, string = prompts.string("Enter a string", "Please enter string:", "Sample Text") #make certain the user said ok before working if response == Gtk.ResponseType.OK: #make a list of the supported media files media_files = Gtk.ListStore(str) #add a dictionary to the list of media files media_files.append({"String":string}) #remove any children in scrolled window for c in self.ui.scrolledwindow1.get_children(): self.ui.scrolledwindow1.remove(c) #create the grid with list of dictionaries #only show the File column media_grid = DictionaryGrid(media_files, keys=["File"]) #show the grid, and add it to the scrolled window media_grid.show_all() self.ui.scrolledwindow1.add(media_grid)

    Read the article

  • UnicodeEncodeError: 'ascii' codec can't encode character [...]

    - by user1461135
    I have read the HOWTO on Unicode from the official docs and a full, very detailed article as well. Still I don't get it why it throws me this error. Here is what I attempt: I open an XML file that contains chars out of ASCII range (but inside allowed XML range). I do that with cfg = codecs.open(filename, encoding='utf-8, mode='r') which runs fine. Looking at the string with repr() also shows me a unicode string. Now I go ahead and read that with parseString(cfg.read().encode('utf-8'). Of course, my XML file starts with this: <?xml version="1.0" encoding="utf-8"?>. Although I suppose it is not relevant, I also defined utf-8 for my python script, but since I am not writing unicode characters directly in it, this should not apply here. Same for the following line: from __future__ import unicode_literals which also is right at the beginning. Next thing I pass the generated Object to my own class where I read tags into variables like this: xmldata.getElementsByTagName(tagName)[0].firstChild.data and assign it to a variable in my class. Now what perfectly works are those commands (obj is an instance of the class): for element in obj: print element And this command does work as well: print obj.__repr__() I defined __iter__() to just yield every variable while __repr__() uses the typical printf stuff: "%s" % self.varname Both commands print perfectly and can output the unicode character. What does not work is this: print obj And now I am stuck because this throws the dreaded UnicodeEncodeError: 'ascii' codec can't encode character u'\xfc' in position 47: So what am I missing? What am I doing wrong? I am looking for a general solution, I always want to handle strings as unicode, just to avoid any possible errors and write a compatible program. Edit: I also defined this: def __str__(self): return self.__repr__() def __unicode__(self): return self.__repr__() From documentation I got that this

    Read the article

  • Help for creating a random String

    - by Max
    I need to create a random string which should be between the length of 6 to 10 but it sometimes generates only about the length of 3 to 5. Here's my code. Can anyone would be able to find out the problem? :( int lengthOfName = (int)(Math.random() * 4) + 6; String name = ""; /* randomly choosing a name*/ for (int j = 0; j <= lengthOfName; j++) { int freq = (int)(Math.random() * 100) + 1; if(freq <= 6){ name += "a"; }if(freq == 7 && freq == 8){ name += "b"; }if(freq >= 9 && freq <= 11){ name += "c"; }if(freq >= 12 && freq <= 15){ name += "d"; }if(freq >= 16 && freq <= 25){ name += "e"; }if(freq == 26 && freq == 27){ name += "f"; }if(freq == 28 && freq == 29){ name += "g"; }if(freq >= 30 && freq <= 33){ name += "h"; }if(freq >= 34 && freq <= 48){ name += "i"; }if(freq == 49 && freq == 50){ name += "j"; }if(freq >= 51 && freq <= 55){ name += "k"; }if(freq >= 56 && freq <= 60){ name += "l"; }if(freq == 61 && freq == 62){ name += "m"; }if(freq >= 63 && freq <= 70){ name += "n"; }if(freq >= 71 && freq <= 75){ name += "o"; }if(freq == 76 && freq == 77){ name += "p"; }if(freq == 78){ name += "q"; }if(freq >= 79 && freq <= 84){ name += "r"; }if(freq == 85 && freq == 86){ name += "s"; }if(freq == 87 && freq == 88){ name += "t"; }if(freq >= 89 && freq <= 93){ name += "u"; }if(freq == 94){ name += "v"; }if(freq == 95 && freq == 96){ name += "w"; }if(freq == 97){ name += "x"; }if(freq == 98 && freq == 99){ name += "y"; }if(freq == 100){ name += "z"; } }

    Read the article

  • A New Threat To Web Applications: Connection String Parameter Pollution (CSPP)

    - by eric.maurice
    Hi, this is Shaomin Wang. I am a security analyst in Oracle's Security Alerts Group. My primary responsibility is to evaluate the security vulnerabilities reported externally by security researchers on Oracle Fusion Middleware and to ensure timely resolution through the Critical Patch Update. Today, I am going to talk about a serious type of attack: Connection String Parameter Pollution (CSPP). Earlier this year, at the Black Hat DC 2010 Conference, two Spanish security researchers, Jose Palazon and Chema Alonso, unveiled a new class of security vulnerabilities, which target insecure dynamic connections between web applications and databases. The attack called Connection String Parameter Pollution (CSPP) exploits specifically the semicolon delimited database connection strings that are constructed dynamically based on the user inputs from web applications. CSPP, if carried out successfully, can be used to steal user identities and hijack web credentials. CSPP is a high risk attack because of the relative ease with which it can be carried out (low access complexity) and the potential results it can have (high impact). In today's blog, we are going to first look at what connection strings are and then review the different ways connection string injections can be leveraged by malicious hackers. We will then discuss how CSPP differs from traditional connection string injection, and the measures organizations can take to prevent this kind of attacks. In web applications, a connection string is a set of values that specifies information to connect to backend data repositories, in most cases, databases. The connection string is passed to a provider or driver to initiate a connection. Vendors or manufacturers write their own providers for different databases. Since there are many different providers and each provider has multiple ways to make a connection, there are many different ways to write a connection string. Here are some examples of connection strings from Oracle Data Provider for .Net/ODP.Net: Oracle Data Provider for .Net / ODP.Net; Manufacturer: Oracle; Type: .NET Framework Class Library: - Using TNS Data Source = orcl; User ID = myUsername; Password = myPassword; - Using integrated security Data Source = orcl; Integrated Security = SSPI; - Using the Easy Connect Naming Method Data Source = username/password@//myserver:1521/my.server.com - Specifying Pooling parameters Data Source=myOracleDB; User Id=myUsername; Password=myPassword; Min Pool Size=10; Connection Lifetime=120; Connection Timeout=60; Incr Pool Size=5; Decr Pool Size=2; There are many variations of the connection strings, but the majority of connection strings are key value pairs delimited by semicolons. Attacks on connection strings are not new (see for example, this SANS White Paper on Securing SQL Connection String). Connection strings are vulnerable to injection attacks when dynamic string concatenation is used to build connection strings based on user input. When the user input is not validated or filtered, and malicious text or characters are not properly escaped, an attacker can potentially access sensitive data or resources. For a number of years now, vendors, including Oracle, have created connection string builder class tools to help developers generate valid connection strings and potentially prevent this kind of vulnerability. Unfortunately, not all application developers use these utilities because they are not aware of the danger posed by this kind of attacks. So how are Connection String parameter Pollution (CSPP) attacks different from traditional Connection String Injection attacks? First, let's look at what parameter pollution attacks are. Parameter pollution is a technique, which typically involves appending repeating parameters to the request strings to attack the receiving end. Much of the public attention around parameter pollution was initiated as a result of a presentation on HTTP Parameter Pollution attacks by Stefano Di Paola and Luca Carettoni delivered at the 2009 Appsec OWASP Conference in Poland. In HTTP Parameter Pollution attacks, an attacker submits additional parameters in HTTP GET/POST to a web application, and if these parameters have the same name as an existing parameter, the web application may react in different ways depends on how the web application and web server deal with multiple parameters with the same name. When applied to connections strings, the rule for the majority of database providers is the "last one wins" algorithm. If a KEYWORD=VALUE pair occurs more than once in the connection string, the value associated with the LAST occurrence is used. This opens the door to some serious attacks. By way of example, in a web application, a user enters username and password; a subsequent connection string is generated to connect to the back end database. Data Source = myDataSource; Initial Catalog = db; Integrated Security = no; User ID = myUsername; Password = XXX; In the password field, if the attacker enters "xxx; Integrated Security = true", the connection string becomes, Data Source = myDataSource; Initial Catalog = db; Integrated Security = no; User ID = myUsername; Password = XXX; Intergrated Security = true; Under the "last one wins" principle, the web application will then try to connect to the database using the operating system account under which the application is running to bypass normal authentication. CSPP poses serious risks for unprepared organizations. It can be particularly dangerous if an Enterprise Systems Management web front-end is compromised, because attackers can then gain access to control panels to configure databases, systems accounts, etc. Fortunately, organizations can take steps to prevent this kind of attacks. CSPP falls into the Injection category of attacks like Cross Site Scripting or SQL Injection, which are made possible when inputs from users are not properly escaped or sanitized. Escaping is a technique used to ensure that characters (mostly from user inputs) are treated as data, not as characters, that is relevant to the interpreter's parser. Software developers need to become aware of the danger of these attacks and learn about the defenses mechanism they need to introduce in their code. As well, software vendors need to provide templates or classes to facilitate coding and eliminate developers' guesswork for protecting against such vulnerabilities. Oracle has introduced the OracleConnectionStringBuilder class in Oracle Data Provider for .NET. Using this class, developers can employ a configuration file to provide the connection string and/or dynamically set the values through key/value pairs. It makes creating connection strings less error-prone and easier to manager, and ultimately using the OracleConnectionStringBuilder class provides better security against injection into connection strings. For More Information: - The OracleConnectionStringBuilder is located at http://download.oracle.com/docs/cd/B28359_01/win.111/b28375/OracleConnectionStringBuilderClass.htm - Oracle has developed a publicly available course on preventing SQL Injections. The Server Technologies Curriculum course "Defending Against SQL Injection Attacks!" is located at http://st-curriculum.oracle.com/tutorial/SQLInjection/index.htm - The OWASP web site also provides a number of useful resources. It is located at http://www.owasp.org/index.php/Main_Page

    Read the article

  • Escaping an equals sign in DOS batch string replacement command

    - by Alastair
    I need to replace some text in a JNLP file using a DOS batch file to tune it for the local machine. The problem is that the search pattern contains an equals sign which is messing up the string replacement in the batch file. I want to replace the line, <j2se version="1.5" initial-heap-size="100M" max-heap-size="100M"/> with specific settings for the initial and max heap sizes. For example at the moment I have, for /f "tokens=* delims=" %%a in (%filePath%agility.jnlp) do ( set str=%%a set str=!str:initial-heap-size="100M"=initial-heap-size="%min%M"! echo !str!>>%filePath%new.jnlp) but the = in the search pattern is being read as part of the replacement command. How do I escape the equals sign so it is processed as text?

    Read the article

  • URLEncoding a string with Objective-C

    - by Chris
    I'm trying to URL encode a string to form a GET request from objective-c. NSString *params = @"'Decoded data!'/foo.bar:baz"; NSRunAlertPanel( @"Error", [params urlEncoded], @"OK", nil, nil ); This is the category extending NSString -(NSString *) urlEncoded { NSString *encoded = (NSString *)CFURLCreateStringByAddingPercentEscapes( NULL, (CFStringRef)self, NULL, (CFStringRef)@"!*'\"();:@&=+$,/?%#[]% ", kCFStringEncodingUTF8 ); return encoded; } So the first time I run it I get back 1606410046ecoded 1606410784ata2270.000000foo.bar0X1.001716P-1042baz from the dialog box. Immediately after I run it again I get this 1606410046ecoded 1606410944ata227369374562920703448982951250259562309742470533728899744288431318481119278377104028261651081181287077973859930826299575521579020410425419424562236383226511593137467590082636817579938932512039895040.000000foo.bar0X1.66E6156303225P+771baz Then if I run it AGAIN it goes back to the first one. It's really weird. If params is set to @"&" or @" " I just get back a "2" (w/o the quotes) in the dialog box. Also is there a way I can have the % signs be shown in the alert dialog? Thanks

    Read the article

  • Reading In A String and comparing it C

    - by ahref
    Im trying to create a C based string menu where a user inputs a command and then a block of code runs. Whatever i do the conditional is never true: char *input= ""; fgets(input, 50, stdin); printf("%s",input); printf("%d",strcmp( input,"arrive\0")); if(strcmp( input,"arrive\0")==0){.... Im fairly new to c and am finding strings really annoying. What am i doing wrong?

    Read the article

  • Finding a pattern within a string variable in C#

    - by lo3
    Ok i'm working on a project for a 200 level C# course, we are required to create a heads or tails project. Basically the project is setup so that the computer will guess randomly up to 5 times, but on the sixth time it will look into the playersGuessHistory variable setup as a string to see if it can find a match for a pattern of 4 entires, if there is a pattern found the computer will guess the next character after the pattern EX: [HHTT]H [HHTTH]H HHTT being the pattern then the computer would guess H for the next turn. My only problem is that i'm having difficulty setting up the project so that it will look through the playersguesshistory and find the patterns and guess the next character in the history. Any suggestions?

    Read the article

< Previous Page | 47 48 49 50 51 52 53 54 55 56 57 58  | Next Page >