Newbie question here.
I have a web form with a text area and naturally users will enter newline characters also. I am storing this form to a table in the DB. I also have to create a report from this. So I dump the table to text and am trying to parse it. The delimiters for me between multiple records is a new line character. But the new line character in the text area is throwing my script off.
I am sure someone must have run into this before. Can you suggest me ideas as to how to deal with this?
I tried having the text from the text area in double quotes but that will complicate my parsing logic. I was wondering if there is an easier way to deal with this.
I think the simple answer is some form of escaping.
You could do some find/replace in the SQL, such as REPLACE(thetext, '\n', '\\n'), or if the newlines are not important, you could do REPLACE(thetext, '\n', ' ')
Recently ran into the same issue. Your best best is to replace the newline characters during the data dump (or before the data gets to your database) with something else. I opted for something like // or <br> so that I can recover the new lines later.
I was trying to build one forum. The problem was when some user enters HTML. It would get translated when you display his post. And I was not able to move to next line when displaying his post. This might help you. I'm using PHP by the way.
$pattern = array('/</','/>/','/\n/');
$replace = array('<','>','<br>');
$post = preg_replace($pattern,$replace,$post);
Related
I when I import a pipe delimited .txt file I receive from a client every once in a while, one of my records will import into the raw table with a line break in the tuple. But when I look at the .txt file I see neither {CR}{LF} or {LF}.
I can't figure out why this is happening. Has anyone else ever experienced this?
I have had similar issues. I ended up stripping out any \n or \r escape characters from string data after it had already come into the data flow using either a derived column or a custom script component. That fixed the problem for me. It helps to enable the data viewer to see what the data looks like as you are debugging.
I have had issues like this before and found that in some cases SSIS could only recognize tabs, linefeeds, & carriage returns using the hexadecimal format:
x0009 - tab
x000A - feed
x000D - return
Try using something like this in your derived column:
(DT_STR,50,1252)TRIM(LOWER(REPLACE(REPLACE(REPLACE( *{your_column}*,"\x0009",""),"\x000A",""),"\x000D","")))
My website has the ability to be viewed in different languages. Is it possible to use sendKeys with a var that looks like this:
var arabic = "صباح الخير
I have tried using:
element(by.css(...)).sendKeys(arabic);
however question marks are the only characters sent to the text box.
Is this possible?
From Protractor point of view, if you see only ??? in input or whatever you are filling the extended chars in, it is probably a bug in that webpage, because generally sendKeys('باح الخير') works absolutely fine.
By the way, silly question, but have you tried pasting those extended chars to input directly, without protractor?
this is probably an easy question but it is driving me mad. I have a form for users to add comments but if there is a ' symbol in the textarea then it will not upload.
I reckon it might have have something to do with the encoding. I am using phpmyadmin and the encoding for the textarea is utf8_gerenal_ci. But I can manually put this symbol into the database. It is only when it is uploaded through the form which has no character restrictions on the textarea.
There may be more symbols that cannot be uploaded. I don't want to have to stop users from using the ' symbol. Hopefully there is a simple answer even if it does make me look stupid. Thank you for your time.
You should do the changes on form part instead of database in this case.
See if this helps you -
How to pass apostrophies from text areas to MySQL using PHP
Try using addslashes() before sending form data to database.
eg. $str = $_POST['form_data];
$str = addslashes($str);
This function will escape all such characters which may cause problems while entering in db.
PLease read: http://php.net/manual/en/function.addslashes.php
I'm currently building an application that generates a separate letter for each user in the dataset. The letter contents are managed through a vb.net application and their RTF format saved to a database. When the letter is created, all the content is pulled from the database to form the letter using vb.net logic.
Once compiled it was sent as a parameter to Crystal. This worked great, setting the field text interpretation to RTF allowed proper RTF viewing.
The client has decided that they would instead like to make changes to the logic (if statements that compile the text) within Crystal.
So what I did was create a blank dataset with a bunch of columns and filled those columns with the RTF (Ordered by ID so the values will never change unless a paragraph is deleted and there is no option for this). This would allow me to build an RTF string by going {table.1} + {table.2} etc...
This is where the problem is. When building an RTF string in a Formula (Using + or &) it only displays the first RTF entry. If I switch the formula to no interpretation, I can see the RTF for the entries written out with all their content so I know it’s there. I also manually combined the RTF in the formula field and had the same issue.
StringVar output;
output := output & "{\rtf1\ansi\ansicpg1252\deff0{\fonttbl{\f0\fnil\fcharset0 Times New Roman;}}\viewkind4\uc1\pard\lang1033\f0\fs23 this is a first test }";
output := output & "{\rtf1\ansi\ansicpg1252\deff0{\fonttbl{\f0\fnil\fcharset0 Times New Roman;}}\viewkind4\uc1\pard\lang1033\f0\fs23 this is a second test \par\par}";
Output
At this point I am unsure if there is a way around this other than moving all the text to separate Formula fields within crystal itself and then combine. This would mean if they wanted to change text it would have to be done within crystal. I would rather not go this route so I’m looking for opinions and suggestions.
Crystal does support RTF however it needs to be fully formed within the first occurance of an RTF entry. In my question it shows two separate COMPLETE RTF entries. As the entries all have the RTF ID tags this will not be possible. The same issue would occur if you copied the above text into a text editor and saved it as RTF. You would only get the first line. This doesnt explain why it works as a parameter and not a formula but its likely how each are evaluated and the later (parameter could loose support in the future).
To Properly pass RTF to crystal you will need to two Rich text box objects. One being a temp box and the other being the builder box and only selecting the formatted text, not the entire RTF content. An example of this can be found at:
http://moneybaron.org/2011/08/23/vb-net-merge-rtf-documents/
Aside from some hacks such as removing the closing brace from the RTF string or rebuilding the RTF table are also avaliable however removing the brace could lead to an unsupported configuration and rebuilding can get messy really quick.
Hope this helps!!
I don't know if this question is so stupid but...
How can i add a newline character to a database registry?
I just want to add a new line character after the input that is shown to the user in the edit or add form.
For example:
//edit view
echo $this->Form->input('reply_above');
I want to send a mail with some information and this string should be at the top separate from the rest of the mail message by a newline.
I have tried this at the edit action in the controller:
$this->request->data['Setting']['reply_separator'].= '<br />';
But then, when i use the mail function it shows the <br /> instead of printing it. (and i really don't want to send the mail in HTML format)
The texts stored on the database don't use a <br /> for new lines. What do they use instead? I have also tried \n but it doesn't work either.
Thanks.
UPDATE
I could be able to add a new line doing this in the edit controller before saving the data:
$this->request->data['Setting']['reply_separator'].="
";
But it really doesn't look like a good solution plus i can not add more than one newline with this method.
Any solutions?
This is your new line character: "\n".
Edit: Be sure to use double quotes not single quote.