How can I encode strings on UTF-16BE format in PHP? For "Demo Message!!!" the encoded string should be '00440065006D006F0020004D00650073007300610067006'. Also, I need to encode Arabic characters to this format.
I have been trying several regular expressions in the substitution operator:
$str =~ s/^0+(.)/$1/;
converts 0000 to 0 and 0001 to 1
$str =~ s/^0+./$1/;
converts 0000 to empty string, 000100 to 00, 0001100 to 100.
what difference is the parentheses making?
I am trying to query the google datastore for something like (with pm -- persistanceManager):
String filters = "( field == 'value' || field == 'anotherValue' )";
Query query = pm.newQuery(myType.class, filters);
When I execute - I am getting back: App Engine datastore does not support operator OR.
What's the best approach in people experience for this kind of queries?
Any help appreciated!
Hi,
if for example i have :
define PRINT(x) fprintf(stderr, x);
and in code i append it :
PRINT(("print this"))
output is :
[print this]
if i append it :
PRINT(("print %s", "this"))
output is :
[this]
could someone explain me why it receives just the "this" argument and not the whole string ?
I am trying to encode a string into a safe url for generic purposes, and neither rawurlencode() nor urlencode() work when using CodeIgniter. I have used them and they work pefectly fine with straight PHP, but for whatever reason, it doesn't work. I haven't been able to find any others with this problem and thus no solution.
Code:
<a href="/search/degree/<?=rawurlencode($row->degree)?>" class="element_link"><?=$row->degree?></a>
In an answer to another question it was mentioned that passing XML as a string parameter to a web service was bad practice. What is the reason for this?
Hi,
I'm using PDO for connect to the database in a system where I want implement memcached.
I don't know what keys use for caching the results because I can't get the string of the final query with PDO (because the prepared statements).
Any good idea for resolve this?
Thanks in advance.
We use cell.getContents to read the values of a cell, the content contains data (e.g. 10.2327), the data gets read as "10.233". Not sure why we are unable to read the string as it is
I understand that CI is mostly URL segment based, but I want to have a query string: blahblah.com/search.html?q=keyword
When I try $this-input-get( "q" ), it returns empty. Is there a route or something I need to configure?
I am working on Java. Here is my code
response = URLEncoder.encode(response, "UTF-8").replaceAll("\\+", "%20");
Problem comes when there is a ' (single quote) in the string response. It gets encoded to \'.
eg - 'Collective Dynamics of Complex Networks' comes as
\'Collective Dynamics of Complex Networks\'
I want it to remain as it is. What should I do?
I'm using grails 2.3.5 with mongodb 3.0.1 and no hibernate installed. I've a domain class which uses mongo's ObjectId.
import org.bson.types.ObjectId
class Category {
ObjectId id
String name
}
And has a record in mongo database:
{
"_id": ObjectId("53f6c34c33a429240e2ab471"),
"name": "art",
"version": NumberLong("41")
}
When I do, Category.get(new ObjectId("53f6c34c33a429240e2ab471")) somewhere in grails app, it returns null but when I do Category.get("53f6c34c33a429240e2ab471") it then actually returns the result.
Why, get() method does not process ObjectId type?
how to write contents in a word doc or pdf in c#
like if i want to write some daily reports generated into word doc or pdf ..in unix we can just pipe the out put to text file can we do that in c# .i know that using string builder we can write the contents to text files can we write the contents to a doc or pdf format ?
I'm trying to build a PHP preg replace string when processing poorly written xml, such that if I am given:
$x='<abc x="y"><def x="g">more test</def x="g"><blah>test data</blah></abc x="y">';
That it checks if there's a space within a closing tag and deletes everything from the space to the end of the tag such that.
becomes
<abc x="y"><def x="g">more test</def><blah>test data</blah></abc>
thanks
Why the following line of code:
private static List list = new ArrayList<String>();
... generates the following warning:
List is a raw type. References to
generic type List should be
parameterized.
I am trying to Write an object stream into a XAML file but i end up in StackoverFlowException .
In the CallStack i could see "The maximum number of stack frames supported by Visual Studio has been exceeded"
This is the piece of code i'm trying to execute.
StreamWriter xamlStream =new StreamWriter(File.OpenWrite("a.xaml"));
string myXaml = System.Windows.Markup.XamlWriter.Save(objectInstance);
xamlStream.Write(myXaml);
Thanks ...!
hi, i want to partially download a ftp file. i just need to download lets say 10MB, but after skipping 100MB (for example).
In php, http://php.net/manual/en/function.ftp-fget.php this function allows arbitay starting point:
bool ftp_fget ( resource $ftp_stream , resource $handle , string $remote_file , int $mode [, int $resumepos = 0 ] )
however it does not allow me to set "how many bytes" i want to download.
I have a file that is tab delimited. I would like a powershell script that counts the number of tabs in each line. I came up with this:
${C:\tabfile.txt} |% {$_} | Select-String \t | Measure-Object | fl count
it yields 3, Which is the number of lines in the file.
any pointers to what I'm doing wrong? I would like it to print a single number for each line in the file.
Hi,
i found a way to send plain text email using intent:
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("text/plain");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new
String[]{"[email protected]"});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Subject");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Test");
But I need to send HTML formatted text.
Trying to setType("text/html") doesn't work.
Hello,
I'm about to develop some commercial software that will run on OSX and Linux. The program will be doing some heavy string manipulation, base64 encoding, zlib compression and may require http libraries in the future.
Does anyone have a suggestion?
Many thanks in advance,
Toby.
I want to check if user input a positive integer number.
1 = true
+10 = true
.1 = false
-1 = false
10.5 = false
Just a positive number.
No characters.
No special character.
No dot.
No minus sign.
I tried is_int() function but it is returning false even on positive integers. Is there a string to int problem?
Thanks
I am trying to extract a number from a string. The number might be zero. Numbers appear like this: '+123', '-8' or '0'.
alert( '+123'.match(/[-?|+?]\d+/) );
alerts +123
alert( '-8'.match(/[-?|+?]\d+/) );
alerts -8
alert( '0'.match(/[-?|+?]\d+/) );
alerts null // why oh why?
How do I get '0'.match(/[-?|+?]\d+/) to return 0 instead of null?
I need a regular expression for which:
the string is alphanumeric and have exactly 6 characters in the first half followed by hyphen(optional) followed by optional 4 characters:(cannot have more than 4 characters in the second half)
so any of the following is valid
11111A
111111-1
111111-yy
yyyyy-989
yyyyyy-9090
I have ^[a-zA-Z0-9]{5}(-[a-zA-Z0-9]{1,3})?$ as the regex expression
what if i want to add another condition stating that the first half cannot have all zeros and also the whole expression cannot have zeros so 00000 or 00000-000 is invalid
I d like to execute a remote javascript which redirects the user to another page on my domain with data that s passes as query string. I want to get this data which is passed on to the page on my domain.
$.getScript('http://site.com/foo.js', function() {
**//foo.js redirects to another page on my domain with data
// and i d like to capture that data from this function,
// at least if i find the parameters that passed on there, i ll be fine.**
});
What to do ?
I need to sum 2 decimal values together, then divide by 2 and convert to string.
My calculation currently is trimming to 2 decimal places, but I want to keep as many decimals as I can.
city.Latitude = ( (lat.North + lat.South) / 2 ).ToString();
the values for lat.North and lat.Souch are like: 55.32342322