Read And Display Japanese Text From Text File
I posted a question regarding reading japanese text from a text file.
Well, since I solved the problem, I thought I'd post my solution for the benefit of other people with the same problem.
The plan was to make a script to read and display japanese text. I will use it for making a japanese proverb script and for a japanese language study script.
Method :
I wrote a simple kanji text file (saved with UTF-8 encoding) I wrote a simple PHP script to display the file contents (saved with UTF-8 encoding) I specified the content-type header for the HTML page : <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
*** All files have the same encoding. ***
UTF-8 supports japanese characters.
and it works!
this is my PHP (and HTML) script :
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>PHP : Japanese Text File Read : Exercise 1</title> </head> <body>
<?php
$filename="japanese.txt"; //open file $fp = fopen($filename,'r');
//loop through each line in the file while($line=fgets($fp)) { //output current text file line print $line."<br>"; } //close file handle fclose($fp);
?>
</body> </html>
I know it's a very simple script, for testing purposes only. It displays the contents of the japanese text file line by line.
The key was to save all files in the same encoding (I used UTF-8) and to specify the encoding / charset in the HTML header (<meta http-equiv="Content-Type" content="text/html; charset=utf-8">)
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Read From A Text File, Output To Browser In Japanese
I am trying to store data in a text file and output it to the browser using PHP. All very easy - if I was using English! the problem is, I want to use Japanese and I'm finding it a tad difficult to get PHP to understand. I have two files, a text file containing data to display and a php file with a script to display the data. I can get the contents of a text file displayed in English, no problemo, but in Japanese, it's another story... All the correct settings are enabled in the php.ini file for Japanese language support (mb_string, input_encoding, output_encoding settings etc..etc..) even if I save the text file, to be read from, in Shift_JIS encoding - I still can't get it to display normally! here's the script I'm using to read the text file : <? $filename="test.txt"; $fp = fopen($filename,'r'); while($line=fgets($fp)) { //output text file line print $line."<br>"; } fclose($fp); ?>
Japanese Text Display
I have Japanese data coming from a mySQL database. It's internal encoding is EUC-JP and it is outputted as SJIS. This actually works just fine. My question comes from the fact that once these changes were made, all the static Japanese text on the page is botched. The meta tag in the head is set to Shift_JIS(SJIS) and it worked before the change. Any suggestions? I just can't see how the two match up... The encoding of the db info shouldn't affect the encoding of static info on the page should it? Especially when they are both output in the same encoding..
Text File Read / Write
im trying to make a poll that uses a text file for storing totals, and...well its not working. I have a text file with 5 values seperated by semicolons, like 1;2;3;4;5, and that file is poll1.txt. If I supply the script with an option, it will succesfuly read and show the contents of the file, but when I try to change one of the values and put it back, it fails. It writes to the file with loads of black squares and more semicolons than are in the $newresults variable. Follows is the incorrect code:
Read Text File And Store In DB
Is it possible to upload a text file, read the contents and extract certain strings, words, phrases, etc. from it and store it in a mySQL database for later searching via the web? If so, are there any scripts/modules out there that accomplishes this?
Read Line From Text File
I have a text file that i would like to use PHP to read from. each line ends with a. I need to read from the beginning of the line, only upto that: right now i'm using this, which is sloppy and slow: if ($chr = fgetc($file)) != "") { } which of course reads in one byte at a time till the end of line. is there a better way?
Read And Write To Text File
I am trying to do a simple thing: read a line from a text file and write this line to another text file. The problem is: when I write the text into the new file there is an empty space between each characters. EG my original line is abcdef and the result is: a b c d e f . I tried and tried, searched google, but I am stuck... How can I read line n from one file and write it to another file exactly the same?
Read The Contents Of A Text File Into MySql Using PHP
New to this, have the basics, can build a form and such. My problem is I need to be able to open a file on a pc/s on the network, read the data character by character, check to see if a certain character is present, if it is, update the database and continue reading the file until it comes across the character again, updates the database and so on . . . .
Webbased Email Client With Japanese Text
I am developing the mail client using PHP, when I try to send a mail using mail() of PHP. All the text written in Japanese language converted to junk characters. How can I send the mail with japanese language using PHP only.
Text File Display
I have a number of SQL reports that create standard 132 column text files. The user wishes to view these files in a browser in addition to their daily printing on a laser printer. I can handle directory structure, etc with PHP but I would like to know what is the best way of displaying these text files on screen. We can select them but they are very plain. Is there a TXT2HTML ot TXT2XML type tool that can display headings, bolding, etc without too much difficulty. I would rather not reprogram the reports as there are hundreds of them, and embedding HTML would not be an answer as they need to be printed on a regular laser.
Mail Function-subject Getting Ascii Charactes For Japanese Text
I am using mail funtion to send mail to some people having japanese text as contents. the data for the mail comes from database where the data is stored in UJIS. while sending the mail i am setting the encoding as UJIS in mail headers. but when the mail is sent using this data, the subject line of the mail gets ascii characters. contents appear in correct japanese,just the problem is with subject one more thing there is no problem with the data stored in database.
Display A Text File On A Web Page
I have a text file that I am trying to display on a web page. If I cat or more the file it formats and displays fine. When it comes up in the browser it seems to loose tabs and the format gets messed up. This is how I display the file. $show = file("./fields/combined/$cdp$store"); $arrayitems = sizeof($show); $x=0; while ($x < $arrayitems) { print("$show[$x] "); $x++; } If I edit the file it has ^M at the end of each line if it matters. Does anyone have a better idea as to how to display it?
Display Results From Text File In Multiple Pages
i use a string, eg "&&&" to mark pages in a text file. i use $count to count the above string. how can i display the contents of this file in multiple pages (by identifying the above string or any other method)?
Display Results From Text File In Multiple Pages
i use a string, eg "&&&" to mark pages in a text file. i use $count to count the above string. how can i display the contents of this file in multiple pages (by identifying the above string or any other method)?
Remove Text Header In Text File
I have been having trouble removeing two header lines at the top of my txt file. You will see in my code the different things I have tried but with no luck. Below I posted my script and data. I am doing a few other things in my script as you will notice but this is the only thing I am having troble with. Code:
Read Text File Line By Line
I have been given a textfile which contains data on 1000 businesses. Each line contains a name and a code which are seperated by a comma. The code below allows me to display the entire textfile but I want to read in the values from each line and store these in a database. $filename = "businesses.txt"; $fileToOpen = fopen($filename,"r"); $content = fread($fileToOpen, filesize($filename)); $content = nl2br($content); fclose($fileToOpen); echo($content); Does anyone know how I can read the data in line by line so that I can store it in a database.
Q: Read Text With VBA From A PHP Web-page
I created a page on our intranet that shows a number and that increases for every time the page is opened. It is similar to a visitors-counter. When I look at the page with Internet Explorer it works just fine. Now I want to read this web-page from a MS-Word macro and include the number as a company wide unique id in my MS-Word document. Unfortunately, the PHP script doesn't update the counter when I call it from my MS-Word macro. How can I force PHP to update my counter when I call it from a VBA macro? I am using the following code:
How To Read HTML Email Text?
I've done a couple of hours web-searching without turning up many answers so far, and I guess I could figure it out (eventually) from the MIME format, but here goes with my question... I don't have any problems reading text emails, but can anybody direct me to some PHP source code that will read (the text inside) an HTML email, specifically the "From", "Subject" and especially the message body? I would like the code to be able to differentiate between (i.e. know that it is) a text or an HTML email, and I would like the code to ignore any attachments. I don't expect the incoming email to have any (or large) attachments, but I hope that any code samples can handle the possible case of big attachments coming along for the ride. Incidentally, if I did (not this time) want to handle large attachments, can PHP and/or servers handle megabytes of data being read into a string variable through fread()? I'm just getting into this stuff, and not sure of what areas would be a resource and/or performance hog.
PHP Will Not Read More Than 4096 From My Microsoft Sql Text Field.
I have a textarea that is saving to a mssql text (very large) field. The insert, update is working fine. However, when php reads the data using mssql_result function, I'm getting limited to 4096 characters read by php. I know that there are at least 6000 characters and I can see them using microsoft's query analyzer. This is not a magic quotes, single quote, quote, html entity or anthing like that. PHP will not read more than 4096 from my microsoft sql text field. Any ideas how I can get php to read more?
Using PHP To Display News Text
I downloaded a php script from hot scripts called Blue Boy Whats New. I really like what he's done on his site for displaying news items. I got the admin part working and can add and edit news items. I can view the page created bb_news.php3, but when I try to include the php3 file in my home page nothing shows up.
Display Html Text From DB
I've got a text box and basically the user types text in html format, I then use htmlspecialchars to convert special characters to HTML entities, fine not a problem I then store the text in a DB with the HTML entities in place. However when I want to display the text from the DB it still has the HTML tags in place and would like to render the HTML so to speak, how do I implement this? Sounds straightforward but need some pointers.
Make Text String Read From Right To Left In Imagettftext() Function
I want to write a text string from right to left instead of from left to right with the imagettftext (); function I read in teh manual that the angle variable controls this, it says that 0 angle means left to right, so I tried 180, 360 but nothing happens What angle do I need to put it to get it to write it right to left I am writing a hebrew text string with a font.ttf that supports hebrew characters <?php $white = imagecolorallocate($background, 255, 255, 255); $fontfile = "davidtr.ttf"; $string = "מחלדגכ"; imagettftext($background, 12, 360, 3, 17, $white, $fontfile, $string); ?>
How To Cut Text And Display It Plus The Remaining Texts
just wanna ask if there's a way I can limit the text length i wanna display and display the remaining text below...?? let's say here's my string: $CallNum = $rows['CallNum']; this contains : Q179:1546:554-abc now i want to display this text like this: Q179: 1546: 554- abc
Display Text In Firebird BLOB
I have a Firebird 2.o Database. When I display the text content of a BLOB field, I get the following result. { tf1fbidisansiansicpg1252deff0{fonttbl{f0fswissfprq2fcharset0 Helvetica;}{f1fswissfprq2fcharset0 Calibri;}{f2fnil MS Sans Serif;}} {colortbl ; ed0green0lue128;} viewkind4uc1pardltrparqclang1033f0fs22 DURBANVILLE CONGREGATIONpar DEDICATED 28TH NOVEMBER 1999par. I use ibase_blob_echo to return a result. How can I get the result to display witout the rtf characters.
How To Display Text On Browser After Forcing Download
how do i display text to my browser after i force a download? heres my working script: Code: $selected_file = "/home/user/somelogfile.log"; header("Content-Type: text/plain"); header("Content-Disposition: attachment; filename=" . $_SERVER[HTTP_HOST] . "_" . $selected_file); header("Content-length: " . filesize($selected_file)); readfile("$selected_file"); what i want to do is display some text in my browser, but if i echo something after readfile(), it gets included in the download file, while i also cant echo before the download as headers need to be sent before any text .
Display MySQL Data In Text Field
I have my site set up and am now working on the admin side. I have a page that lets me search my users then its linked to another page so I can edit the information. I am attempting to get the code to display in my forms text boxes and text areas for updating. My problem is that I can't figure out how to get the data into my form for editing. I have a few different things but can't seem to figure this out.
Identify Url Written In Text Area And Display It Hyperlinked.
I am using html textarea control. user writes text in text area and i save it in database using php, then i display it where ever it is required. I want if user writes some url in the area like www.abc.com or http://www.abc.com , When i display this text as output this url must be shown there as hyperlink. by clicking over it user must be redirected to www.abc .com Is there any html textarea control property that can do it, or i need to write some php or javascript code for it. If someone has php script for it please help. It is urgent.
Quickly Adding Text To A Mysql Text Field That Is NOT Empty
Is there a way to insert text into a mysql text field that already has text into it; without having first to extract the existing data and append the new text to that string variable and then insert the new string. Basically i'm looking for a way to do it with a single query not 2 (one being a select to gather existing data).
Gaining Access To How MySql Parses Text For Full Text
I want to gain access to the function or process MySql uses to parse words and phrases for Full Text searching. Here is an example. If the user inputs... Milan in history MySql will search for milan, history, and milan history. Is there a way to extract just the combination of terms MySql uses to search the db without the stop words? Stop words are automatically eliminated from the search request unless the user encloses a phrase in quotes. What I am trying to do is develop a script to highlight found search terms and phrases. I can explode a phrase into single words but if I do that the stop words would be included in the array. If there is some way of getting into the parsed words or phrases MySql Full Text actually uses to search, I can use each of those combinations as a keyword in my highlighting script. This request is about searching for the code or any code related to the questions involved.
Text Area Not Accepting Large Amounts Of Text
I have a form where teachers enter homework assignments and they are then stored in a MYSQL database and retrieved elsewhere. I have been using "get" with the form. The code is simple: <textarea name="array[assignment]" cols="60" rows="10" id="array[assignment]"></textarea> It does allow post of 100 words, etc. Stuff that teachers normally submit. What's happening is that it won't allow very large posts (over 300 words maybe? ) Not sure what the cut off is. When you press submit it won't go, or there is an error where it won't submit. Is there a limit for text fields? Since the fields scroll, I didn't think that having only 60 rows was any type of real limit, I though you could put in as much as needed. But then all of it ends up in the address bar, so there must be a limit of some sort.
Append Text At End Of Existing Text On Same Line
I'm working on a part of my web site that uploads images, then writes the name of the image to a text file. The upload part works fine. The part that writes the name of the image to the text file works fine. What I'm trying to do is, after all the files have been uploaded and all of the image names have been written to the WriteTo.txt file, append a written description of the picture at the end of the picture name. In other words, after a user uploads their pictures to the server I want to direct them to a page where they can label each of the pictures using a form. PHP Code:
Adding Text To Text Window With A Button
I have made an admin section of a site, What i want to do i have buttons under that have "BOLD" "center" and when clicked it adds <b></b> tags to the text area etc etc.. if the text area was called "message" how would i going about coding the images / buttons to add the code?
PHP - Using Mail() And Unicode Text - Text Gets Disturbed
I have the following problem. On a website there's a (simple) feedback form. This is used also by Polish visitors who (of course) type Polish text using special characters. However, when I receive the text in my mailbox, all special characters have been turned into mess...... For example: "wspólprace" is turned into "współprace". It seems PHP is handling the Unicode-8 strings quite well (when I 'echo' the strings on the site, I see the text correctly), until the point that it is send by using mail(). Is this a server configuration issue? Or something else? How can I get my text to remain in Unicode? I have this problem both on my testserver (Apache 1.3.28, PHP 4.3.2 on Windows XP) as on my providers server (Apache under Linux).
Parsing Text - Capture Text Between Two Tags
I want to have text in files, such as {body} {/body} and then be able to open that file and grab all of the data inbetween those tags. I could open the file and go through it until I see the {body} tag and then store data until I reach {/body} but that is a bad way to do it.
Text Returned From DB Gets Cutoff When Placed In A Text Field
I have a string that contains an apostrophe or a quotation mark, stored in a DB. I can retrieve the data, and display it properly (for editing) in a textarea, but when I try to put the string in a text field, it get's cut off right before the questionable character. For example: $string_in_database = "John's car." -displays correctly here <textarea><?php print $string_in_database ?></textarea> and displays this - John's car. -gets cutoff here <input type='text' value=''<?php print $string_in_database ?>' /> and displays this - John I've tried adding slashes and stripping slashes and I just can't figure out what I need to do.
Keep Text In Text Boxes After Form Is Rewritten
I'm trying to make a form that does the following: (1) the user answers a question by typing in a text box (2) a response is then written below the form, saying whether the answer is right or wrong and, perhaps making a comment of some kind (3) the user's answer remains visible in the original text box I've managed to write some code that does the first two things, but despite many attempts and much searching for code examples, I've failed to find a way of getting the answer to reappear in the text box when the page is rewritten. This is my code:
Replacing Text For Use In A Text Area...
I have a PHP page that allows a user to preview an email and then send it if(s)he is happy with it. Otherwise, they can click on an edit button and edit the text of the message. The text is then shown in a textarea element. While in situation A (the preview), a bit of formatting is useful (e.g <BR>), all of this formatting is a nuisance in the textarea. Basically, I would like to do the following: a. replace <BR> with a line break for the textarea b. get rid of double spaces and tabs before the text is loaded in the textarea c. put the <BR>s back in when the user is finished with editing the message. Is there a way to do this?
Text Box To .txt File
does anyone know how to make a text box in php that when submitted, it writes to a .txt file?
Saving To A Text File.
I haven't been able to find a way to save the results of a MYsql query into a tab delimited text file... Anyone know how to do this, or if there are any already written scripts out there that perform this, or a similar function?
Database Row To Text File
I need to get the contents of a MySQL database field into a text file, and write the file to the server. I can not seem to get any filesystem functions to work, because it tells me I do not have permission to do anything. I am on virtual hosting, so it seems easier for me to try to FTP files to my own server. Perhaps you guys can give me some pointers, this is kind of the idea I am running on:
Writing To A Text File
i have a text file with the number 250 in it and nothing else. i have a variable which is worth a 300. How can i add this value to the one in the file so that the value of the file has changed to 550?
Text File Into Variable
I'm setting up an script that will send mail to an address given by a user. The problem is that the body of the e-mail varies depending on a few responses that the person gives, and writing out like 1000 lines of code just to get each of the outcomes covered is not my idea of fun. My question is, is there any way to make a variable in PHP the contents of a .txt file so I don't have to have that big of a script?
|