Welcome to Dream.In.Code
Getting PHP Help is Easy!

Join 132,673 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,194 people online right now. Registration is fast and FREE... Join Now!




How i can view RTF format from a field of table (mySQL-PHP)

 
Reply to this topicStart new topic

How i can view RTF format from a field of table (mySQL-PHP)

lehoangvu
post 7 Aug, 2007 - 02:05 AM
Post #1


New D.I.C Head

*
Joined: 7 Aug, 2007
Posts: 1


My Contributions


I have a table USER (ID, Name), and now i want to show Name on PHP page, but field Name have format RTF (Rich Text Format) so view not correct. For example: {\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fprq2\fcharset163 Verdana Ref;}{\f1\fswiss\fprq2\fcharset163 Verdana Ref;}{\f2\fnil\fcharset128 MS Mincho;}{\f3\fnil\fcharset129 MS Mincho;}{\f4\fnil\fcharset134 MS Song;}{\f5\fnil\fcharset136 MS Song;}{\f6\fswiss\fprq2\fcharset161 Verdana Ref;}{\f7\fswiss\fprq2\fcharset162 Verdana Ref;}{\f8\fswiss\fprq2\fcharset177 Verdana Ref;}{\f9\fswiss\fprq2\fcharset178 Verdana Ref;}{\f10\fswiss\fprq2\fcharset186 Verdana Ref;}{\f11\fswiss\fprq2\fcharset204 Verdana Ref;}{\f12\fswiss\fprq2\fcharset222 Verdana Ref;}{\f13\fswiss\fprq2\fcharset238 Verdana Ref;}{\f14\fswiss\fprq2\fcharset130 Verdana Ref;}} {\colortbl ;\red0\green0\blue0;}\viewkind4\uc1\pard\lang1066\f0\cf1\fs18 \par
xem \ul tec\ulnone \par
}
.
How i can do?
Help me!
Thanks!
User is offlineProfile CardPM

Go to the top of the page

Martyr2
post 7 Aug, 2007 - 01:29 PM
Post #2


Programming Theoretician

Group Icon
Joined: 18 Apr, 2007
Posts: 5,062



Thanked 175 times

Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions


You are going to have to find yourself a PHP rtf parser class that can parse out the control codes and render the text as HTML. There are a few on the net that you can try but keep in mind that the RTF specification is being updated all the time with new control codes. So if the parser class does not ignore codes it doesn't understand it may crash. Good parsers will ignore control codes it doesn't understand and it will keep a look out for \bin or binary control codes when counting curly braces during parsing.

If it was me I wouldn't have had this field in RTF format to begin with. Databases should try and keep styling information out of its content. Styling should be controlled by stylesheets or a program rendering the data itself.

The following link does have a parser as part of the "accepted solution". Keep in mind though that this page will put limits on how often you can view the answer, so once you see it, copy and paste it to notepad and save it immediately. You will need to scroll down to the second half of the page to accepted solution.

Enjoy!

Expert Exchange RTF Parser class as accepted solution
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/23/08 06:21AM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month