text

PHP - Storing Text in MySQL Database

I have a textbox on my website and I need to store whatever the user enters into my database, and retrieve it at a later time. I need to store it exactly as the user entered, including special characters, carriage returns, etc. What process should I use in PHP to store this in my database field (which is a 'text' field)? Should I use PH...

How can I save a PNG with a tEXt or iTXt chunk from Java?

I am currently using javax.imageio.ImageIO to write a PNG file. I would like to include a tEXt chunk (and indeed any of the chunks listed here), but can see no means of doing so. By the looks of com.sun.imageio.plugins.png.PNGMetadata it should be possible. I should be most grateful for any clues or answers. M. ...

Compare many text files that contain duplicate "stubs" from the previous and next file and remove duplicate text automatically

I have a large number of text files (1000+) each containing an article from an academic journal. Unfortunately each article's file also contains a "stub" from the end of the previous article (at the beginning) and from the beginning of the next article (at the end). I need to remove these stubs in preparation for running a frequency an...

Swing component prints text differently than it displays it

I am printing a Swing component that contains text. The Swing component renders the text just fine on the screen, but, when I print it (to a .tif file), the characters are all smashed together. Why is this? Run this code to see what I mean: import javax.swing.*; import javax.swing.text.MutableAttributeSet; import javax.swing.text.Sim...

Is there any difference between +-ing strings and <<-ing strings in c++?

What is the difference, if any between the effects of the following snippets: cout << "Some text" << s1 << "some more text\n"; cout << "Some text" + s1 + "some more text\n"; ...

draw text with GLUT / OpenGL in Python

Hey, I m drawing text with OpenGL in Python. It all works ok, however the font is really bad. If I make it thick the letters start to look very occurred (especially the ones which are round like 'o' or 'g'. For the purpose of my program it must be thick. Is there any font I could use which does not look so bad when thickened, or is ther...

Looking for text editor with directory treeview

If I could have a directory treeview inside of Sublime Text I'd be happy as a peach, because I haven't found a more elegant editor. Can't use TextMate because I don't have a Mac. ...

HTML textbox, auto highlighting text

How would I make a textbox, containing preexisting text, that when the user clicked within it all the text inside it would become highlighted. For example, the same way YouTube does the textboxes for the embed code on their videos. Thanks ...

Eliminate gap between lines of text

When you increase the line-height of an element, you start getting gaps between each line of text. Most of the time this is fine, since you don't see the specific gap. But it is problematic when you have a narrow column, with a link that runs over multiple lines. If you move your mouse over the link, there is a small gap between the lin...

How to find high frequency words in a book in an environment low on memory?

Recently in a technical interview, I was asked to write a program to find the high frequency words(Words which appear maximum number of times) in a text book. The program should be designed in such a way that, it processes the entire text book with minimum memory. Performance is not a concern. I was able to program to find the frequency ...

Something wrong with output from list in python

I want python to import a list of words from a text file and print out the content of the text file as two lists. The data in the text file is on this form: A Alfa B Betta C Charlie I want python to print out one lists with A,B,C and one with Alfa, Betta, Charlie This is what i've written: english2german = open('english2german.txt'...

Displaying lines from text file in a batch file

Hi I'm tryin' to find a script that will let me display "linenumber# and linenumber# as well as lines#-#" from a text file in a batch file? I found this script here on this site.. @echo off setlocal enabledelayedexpansion if [%1] == [] goto usage if [%2] == [] goto usage SET /a counter=0 for /f "usebackq delims=" %%a in (%2) do ( if "...

matrix text style in action script

Hi, I am working in AS3, and I was wondering if anyone knew how to create a matrix effect (the moving green text lines in the movie) in action script. I have found a few examples online, but none of them seem to work. Thanks. ...

Summarise text

If I have some text that I want to print out on a page, but only want to print say the first 100 words before eclipsing it... what's the easiest way to do this? ...

Writing text with carriage return to image in Python using PIL

Hello, I have a python script that is writing text to images using the PIL. Everything this is working fine except for when I encounter strings with carriage returns in them. I need to preserve the carriage returns in the text. Instead of writing the carriage return to the image, I get a little box character where the return should be. ...

Database design for text revisions

This question contains some excellent coverage of how to design a database history/revision scheme for data like numbers or multiple choice fields. However, there is not much discussion of large text fields, as often found in blog/Q&A/wiki/document type systems. So, what would be considered good practice for storing the history of a te...

Cannot insert string into MySQL text column

For some reason, my queries screw up when I write to a column of type "text". Here is an example: Describe messages; Format is: Field Type Null Key Default id int(11) NO PRI NULL auto_increment title varchar(255) YES NULL body text YES NULL to text YES NULL content_type varchar(255) YES NULL is_sms tinyint(1) YES ...

Perform a lot of replacements in a text file using a huge list of replacement pairs

Given: file a.txt containing many millions of lines (say, one sentence per line) (2.6 gb!) file b.txt containing 830k lines with pairs "[word1] [word2]" Question: how to perform the most efficient replacement of each word1 by word2 for every of 830k tuples (w1, w2) in the huge text file? Naive methods like sed, perl, python etc. wo...

Shell: insert a blank/new line two lines above pattern

I have a text file and it requires some formatting. I know that if you want to add a blank line above every line that matches your regexp, you can use: sed '/regexp/{x;p;x;}' But I'd like to add a blank line, not one line above, but two lines above the line which matches my regexp. The pattern I'll be matching is a postal code, in th...

Highlight text in messagebox

I need to display a message box but the user needs to be able to highlight and copy the text in the message box. How would I achieve this? FYI this in in C#. ...