You Are Here:

Community: Developer Discussion Boards

#1 Old Question ASCII line breaks not working - 2006-03-04, 09:41

Join Date: Feb 2006
Posts: 168
Location: Helsinki, Finland
RICH?
Offline
Regular Contributor
Hello

I'm developing a text editor which I intend to use to make HTML and other ASCII files. The files must be ASCII for the HTML to work.

The problem is that when I try to save a file with a line break it just gives me an error and it saves an empty file.

I have tried .encode("utf-8") but its no use to me because it saves into Unicode and I need ASCII.

My code:
Code:
...
# create the file
file = open(filename,'w')

# write text into it
file.write(appuifw.app.body.get())

# close the file
file.close()
...
Can somebody help me?
Reply With Quote

#2 Old Re: ASCII line breaks not working - 2006-03-04, 12:15

Join Date: Jan 2006
Posts: 15
kajinka13's Avatar
kajinka13
Offline
Registered User
in this way it knows to you in unicode....

import codecs

...
# create the file
file = codecs.open(filename,'w', 'utf_8')

# write text into it
file.write(appuifw.app.body.get())

# close the file
file.close()
...
Reply With Quote

#3 Old Re: ASCII line breaks not working - 2006-03-04, 14:21

Join Date: Feb 2006
Posts: 168
Location: Helsinki, Finland
RICH?
Offline
Regular Contributor
Now it saves the file but when I type:
<html>
<body bgcolor="#0000ff" text="#ff0000">
Hello
</body>
</html>

It gets saved as:
<html>
<body bgcolor="#0000ff" text="ff0000">
Hello
</body>
</html>

The html doesnt work properly because its not ASCII.
I dont understand why it doesnt get saved in ASCII.

Any ideas?
Last edited by RICH? : 2006-03-04 at 14:33.
Reply With Quote

#4 Old Re: ASCII line breaks not working - 2006-03-04, 18:38

Join Date: Feb 2005
Posts: 1,353
Location: Belgium (Europe)
cyke64's Avatar
cyke64
Offline
Super Contributor
Quote:
Now it saves the file but when I type:
<html>
<body bgcolor="#0000ff" text="#ff0000">
Hello
</body>
</html>

It gets saved as:
<html>
<body bgcolor="#0000ff" text="ff0000">
Hello
</body>
</html>

The html doesnt work properly because its not ASCII.
I dont understand why it doesnt get saved in ASCII.

Any ideas?
"
" I think these characters are 0xE280A9 (end of paragraph !) You must replace them by Ox0D0A.
Look previous post with Listbox and editor on phones in the forum !
Reply With Quote

#5 Old Question Re: ASCII line breaks not working - 2006-03-05, 10:15

Join Date: Feb 2006
Posts: 168
Location: Helsinki, Finland
RICH?
Offline
Regular Contributor
Isn't there any kind of quick way to get a simple thing like line breaks working?
It should work automatically.
Reply With Quote

#6 Old Re: ASCII line breaks not working - 2006-03-05, 20:31

Join Date: Aug 2004
Posts: 290
simo.salminen
Offline
Regular Contributor
See this discussion for help: http://discussion.forum.nokia.com/fo...ad.php?t=75517
Reply With Quote

#7 Old Question Re: ASCII line breaks not working - 2006-03-06, 09:52

Join Date: Feb 2006
Posts: 168
Location: Helsinki, Finland
RICH?
Offline
Regular Contributor
But the HTML files still don't work.
It should work just like Windows Notepad and save as ASCII not utf-8.
I dont understand it.
Last edited by RICH? : 2006-03-07 at 14:54.
Reply With Quote

#8 Old Re: ASCII line breaks not working - 2006-03-09, 12:59

Join Date: Aug 2004
Posts: 290
simo.salminen
Offline
Regular Contributor
Use unicode_string.encode("ascii"). Also, please read this before asking further questions: http://www.joelonsoftware.com/articles/Unicode.html.
Reply With Quote

#9 Old Re: ASCII line breaks not working - 2006-03-10, 09:52

Join Date: Feb 2006
Posts: 168
Location: Helsinki, Finland
RICH?
Offline
Regular Contributor
Yeah Ive read that now.
I got some information on the subject and Ive found out that the character you get when you press "0" isnt a ordinary line break. I need a script which checks the input for the ...well... unordinary line break and changes it to the normal one.


Nokia E66
PyS60 1.4.4 final
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem in compiling Code \Examples\stdlib\guiapp in SDK Ser 60/ Code Warrior senthilashok General Symbian C++ 3 2007-01-18 12:27
problem with Code Warrior 5.2 mayankkedia General Symbian C++ 4 2006-06-22 09:26
code warrior problems mayankkedia Carbide.c++ IDE and plug-ins 2 2004-10-25 07:59
problem with codewarrior 5.2 mayankkedia Symbian Tools & SDKs 3 2004-09-27 17:08
CRichText - A simple working few line example rmuralidharan General Symbian C++ 1 2003-02-12 08:53

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia