string-length

PHP: whats the total length of a post global variable?

旧街凉风 提交于 2019-11-27 13:58:18
I was wondering if anybody knows the total length that a post global could be. e.g: $_POST['formInput'] = "hello world, how long can i be?"; I am creating a site where someone will enter an unknown amount of chars into a textarea, so potentially it could be 2 pages on a word document. So if anybody knows of any other methods of how i can do this apart from using a post global? (it cant be saved in a file, as its important data that i dont want other people to find) That would be very helpful. Thanks Check your php.ini for post_max_size . This is typically about 8mb by default, but if you're on

Measure string size in Bytes in php

亡梦爱人 提交于 2019-11-27 11:53:10
I am doing a real estate feed for a portal and it is telling me the max length of a string should be 20,000 bytes (20kb), but I have never run across this before. How can I measure byte size of a varchar string . So I can then do a while loop to trim it down. You have to figure out if the string is ascii encoded or encoded with a multi-byte format. In the former case, you can just use strlen . In the latter case you need to find the number of bytes per character. the strlen documentation gives an example of how to do it : http://www.php.net/manual/en/function.strlen.php#72274 You can use mb

What is the string length of a GUID?

那年仲夏 提交于 2019-11-27 05:51:59
I want to create a varchar column in SQL that should contain N'guid' while guid is a generated GUID by .NET ( Guid.NewGuid ) - class System.Guid. What is the length of the varchar I should expect from a GUID? Is it a static length? Should I use nvarchar (will GUID ever use Unicode characters)? varchar(Guid.Length) PS. I don't want to use a SQL row guid data-type. I am just asking what is Guid.MaxLength . It depends on how you format the Guid: Guid.NewGuid().ToString() => 36 characters (Hyphenated) outputs: 12345678-1234-1234-1234-123456789abc Guid.NewGuid().ToString("D") => 36 characters

Automatic adjustment of margins in horizontal bar chart

不打扰是莪最后的温柔 提交于 2019-11-27 02:01:37
问题 I need to produce a series of horizontal grouped bar charts. The barplot function does not automatically adjust the margins of the plot, therefore the text gets cut off. graphics.off() # close graphics windows test <- matrix(c(55,65,30, 40,70,55,75,6,49,45,34,20), nrow =3 , ncol=4, byrow=TRUE, dimnames = list(c("Subgroup 1", "Subgroup 2", "Subgroup 3"), c( "Category 1 Long text", "Category 2 very Long text", "Category 3 short text", "Category 4 very short text" ))) barplot(test, las=2, beside

How to get the size of a string in Python?

℡╲_俬逩灬. 提交于 2019-11-27 00:03:57
For example, I get a string: str = "please answer my question" I want to write it to a file. But I need to know the size of the string before writing the string to the file. What function can I use to calculate the size of the string? user225312 If you are talking about the length of the string, you can use len() : >>> s = 'please answer my question' >>> len(s) # number of characters in s 25 If you need the size of the string in bytes, you need sys.getsizeof() : >>> import sys >>> sys.getsizeof(s) 58 Also, don't call your string variable str . It shadows the built-in str() function. Igor

Is using strlen() in the loop condition slower than just checking for the null character?

隐身守侯 提交于 2019-11-26 23:34:26
问题 I have read that use of strlen is more expensive than such testing like this: We have a string x 100 characters long. I think that for (int i = 0; i < strlen(x); i++) is more expensive than this code: for (int i = 0; x[i] != '\0'; i++) Is it true? Maybe the second code will not work in some situation so is it better to use the first? Will it be better with the below? for (char *tempptr = x; *tempptr != '\0'; tempptr++) 回答1: for (int i=0;i<strlen(x);i++) This code is calling strlen(x) every

How to get the number of characters in a std::string?

╄→尐↘猪︶ㄣ 提交于 2019-11-26 18:39:49
How should I get the number of characters in a string in C++? Eclipse If you're using a std::string , call length() : std::string str = "hello"; std::cout << str << ":" << str.length(); // Outputs "hello:5" If you're using a c-string, call strlen() . const char *str = "hello"; std::cout << str << ":" << strlen(str); // Outputs "hello:5" Or, if you happen to like using Pascal-style strings (or f***** strings as Joel Spolsky likes to call them when they have a trailing NULL), just dereference the first character. const char *str = "\005hello"; std::cout << str + 1 << ":" << *str; // Outputs

SQL Server 2008 Empty String vs. Space

浪子不回头ぞ 提交于 2019-11-26 18:35:12
I ran into something a little odd this morning and thought I'd submit it for commentary. Can someone explain why the following SQL query prints 'equal' when run against SQL 2008. The db compatibility level is set to 100. if '' = ' ' print 'equal' else print 'not equal' And this returns 0: select (LEN(' ')) It appears to be auto trimming the space. I have no idea if this was the case in previous versions of SQL Server, and I no longer have any around to even test it. I ran into this because a production query was returning incorrect results. I cannot find this behavior documented anywhere. Does

Is null character included while allocating using malloc

会有一股神秘感。 提交于 2019-11-26 16:46:05
问题 I have been using C for quite sometime, and I have this trivial problem that I want to query about. Say i want to create a character array that stores upto 1000 characters. Now, when I am using malloc for the same, then do I specify the size of array as 1001 character [ 1000 characters + null] or just 1000? Also, say I came across this problem, then how could I have found the answer to this solution on my own, maybe by using some test programs. I understand the size of string is calculated

Calculate the display width of a string in Java

你离开我真会死。 提交于 2019-11-26 16:06:40
How to calculate the length (in pixels) of a string in Java? Preferable without using Swing. EDIT: I would like to draw the string using the drawString() in Java2D and use the length for word wrapping. If you just want to use AWT, then use Graphics.getFontMetrics (optionally specifying the font, for a non-default one) to get a FontMetrics and then FontMetrics.stringWidth to find the width for the specified string. For example, if you have a Graphics variable called g , you'd use: int width = g.getFontMetrics().stringWidth(text); For other toolkits, you'll need to give us more information - it