string

Variant * to string throws unknown exception.

I am using this code to sink events in a IWebBrowser2 webbrowser on c++: STDMETHODIMP AdviseSink::Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pDispParams, ...

C - Copy string into a linked list variable

#define STRLEN 65 /*Create linked list */ struct node { char str[STRLEN]; struct node *next; }; newInput = malloc(sizeof(struct node)); strcpy(newStr, newInput->str); I left the other parts of the code, but it doesnt seem to be copying the string into newInput->str. The string accepted is only 64 bytes. It's just blank when...

PHP - check if a string has 2 words, and if true append a html tag to the 2nd one

Whats the fastest possible way to do this? I think the code below works, but I'm sure there's a faster way to achieve what I want: $words = explode(" ", $string); if(!empty($words[1]) $words[1] = '<span>'.$words[1].'</span>'; $string = implode(" ", $words); What do you think? ...

Copying a BSTR into a char[1024]?

I am working on a web browser with c++ using IWebBrowser2. Declared on the top, outside any scope, I have this: static char buf[1024]; In the documentcomplete event, I set the BSTR with: CComBSTR bstrHTMLText; X->get_outerHTML(&bstrHTMLText); What I want to do is to copy bstrHTMLText value into buf (if bstrHTMLText length is > 1024...

Binary search on C++ string does not work.

What is wrong with the following code? How come it does not found the letter using my implementation of a binary search? #include <iostream> #include <string> #include <algorithm> #include <cctype> #include <cwctype> using namespace std; bool contains(string s, char a){ int m = 0; int n = s.length()-1; while (m != n) { int k...

Extracting HTML Data with Curl / PHP

I have the following code in PHP $ch = curl_init("http://blog.com"); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($ch); curl_close($ch); echo $output; I am trying to i...

Algorithm used by Google Chrome for string search ?

Does any one know which is the algorithm used by the browser google-chrome for searching strings [shortcut:CTRL+F] ? Is it Boyer-moore algorithm ? ...

Google Map marker coordinate string to number

I am trying to create a Google Map with a single coordinate as marker. I use ASP MVC, and the coordinates are saved in the database as a string. <%: Model.LatLng %> outputs something like this: 52.425, 4.938 The problem is, Google Maps cannot read this, probably because it is a string. How do I convert the coordinates to something...

Difference between char *str="STRING" and char str[] = "STRING" ?

Hello, While coding a simple function to remove a particular character from a string, I fell on this strange issue: void str_remove_chars( char *str, char to_remove) { if(str && to_remove) { char *ptr = str; char *cur = str; while(*ptr != '\0') { if(*ptr != to_remove) { ...

Cannot pass string through classes

//Initialize the detail view controller and display it. OrderDetailsView *dvController = [[OrderDetailsView alloc] initWithNibName:@"OrderDetailsView" bundle:[NSBundle mainBundle]]; dvController.selectedOrder = (@"%@",selectedOrder); [self.navigationController pushViewController:dvController animated:YES]; [dvController release]; dvContr...

String to Number and back algoritm

This is a hard one (for me) I hope people can help me. I have some text and I need to transfer it to a number, but it has to be unique just as the text is unique. For example: The word 'kitty' could produce 12432, but only the word kitty produces that number. The text could be anything and a proper number should be given. One problem t...

How can i extract the portion of a string giving the beginning and the end position?

How can i extract the portion of a string giving the beginning and the end position? I know there is a method called substr() but is not what im looking for (the third parameter is lenght of the portion..) ...

PHP: trying to substract the returning values from strpos()

Hi, i have this code: <?php var_dump(strpos($url, "cashgold.")+9) ?> <?php var_dump(strpos($url, '/', 8)) ?> <?php $resta = strpos($url, '/', 8) - strpos($url, "cashgold.")+9 ?> <?php var_dump($resta) ?> this prints: 20 22 20 I expected it prints : 20 22 2 Any idea? Regards Javi ...

Get list of {} templates from String [PHP]

Hi, I want to get the template words in a string. Template in the sense of words in {} inside a string. I am adding here a code to explain what I want exactly. $string = "Hi {username}, Here is your {password}"; function get_template_variables($string) { .... .... return array(); } $result = get_template_variables($strin...

XSL matching strings trouble

Hi all, I've been having the issue from here: http://stackoverflow.com/questions/3840502/sharepoint-issue-selective-behavior and I think I've narrowed the problem down to this XSL code: <xsl:if test="contains(translate(string(@Author), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'ab...

trying to replace "\" char using javascript for a json parser

so I have the following line of javascript: YAHOO.lang.JSON.parse(txt) where text is a string that is pulled from the database. This is an example of one of the problem strings I'm getting back: 5000\25\30% The JSON parser is throwing syntax errors on the / character as far as I can tell. I looked through threads here and most of t...

Python: 2.6 and 3.1 string matching inconsistencies

I wrote my module in Python 3.1.2, but now I have to validate it for 2.6.4. I'm not going to post all my code since it may cause confusion. Brief explanation: I'm writing a XML parser (my first interaction with XML) that creates objects from the XML file. There are a lot of objects, so I have a 'unit test' that manually scans the XML ...

flash as3 string encode decode

I want to encode / decode a string in AS3: var string:String = "This is an text"; encode(string) will give for example: "yuioUasUenUwdfr" decode(encoded(string)) will give: "This is an text"; It does not have to be secure or anything. Thnx! ...

How to determine if all characters in a string are equal.

I need to know if all characters in a string are equal (formed by the same character). the function must return true or false depending if all the elements of the string are equal to an particular char. I wrote this function that works well, but I'm looking for a more optimal (fastest) solution, the strings can have thousands of chars...

Regex Replace All Characters in Variable Length String

Hi Using VB or C#, I am getting a string of variable length from the database. This information is sensitive information that only certain users will be able to see. I have two cases that will use the same logic (I think). scenario 1: replace all characters with x scenario 2: replace all characters with x except the last 4 characters...