LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-23-2003, 01:25 PM   #1
maseby
Member
 
Registered: Oct 2003
Posts: 42

Rep: Reputation: 15
Question python2 programming


Need help!!!!!!!!!!



I trying to run a .py file in python2 interpreter...but the thing is that this file contains the swedish letters ä,å,ö

so the output is missing these letters...instead there is some other funny characters.....

I know that I am susposed to have the latin6 package on with the nordic iso-8859-10 encoding system....


but the thing is...that I dont know how to
 
Old 10-24-2003, 03:07 PM   #2
Mega Man X
LQ Guru
 
Registered: Apr 2003
Location: ~
Distribution: Ubuntu, FreeBSD, Solaris, DSL
Posts: 5,339

Rep: Reputation: 65
I dunno how it is in python (it has been a long time since I last worked with it) but in C/C++ you need to get the handle of scape sequences to perform Swedish (or whatever other characters outside the ASCII table) to do not get weird characters. Here is some examples:

#include <iostream>
using namespace std;

int main()
{
unsigned char tecken;
tecken = '\x84'; // Det här är hex till tecknet ä, decimal-kod är 132


// tecken = '\x86'; // Det här är hex till tecknet å, decimal-kod är 134
// tecken = '\x94'; // Det här är hex till teckent ö, decimal-kod är 148

cout << tecken << "\n\n";

return 0;
}

I mean that if you want to write :

"Mitt namn är Megaman X", it should be:

"Mitt namn \x84r Megaman X". So it's sure to work at the console without a problem. Check to see if python supports either hex or scape sequences(I really cannot remember, been coding with it and pygame but I don't remember needing it). A complete list of characters is found here:

http://www.asciitable.com/

Lycka till!
 
Old 10-24-2003, 03:17 PM   #3
Mega Man X
LQ Guru
 
Registered: Apr 2003
Location: ~
Distribution: Ubuntu, FreeBSD, Solaris, DSL
Posts: 5,339

Rep: Reputation: 65
More details to find the hex code. After finding the character in questions from the ASCII table, let's say "ä", it has code decimal 132 right? Open a calculator with advanced options (as hex and oct.) type 132, then choose hex. You will see that the hex code of the number 132 is 84, that's how I came up with '\x84' sequence.

Vi ses
 
Old 10-26-2003, 03:47 AM   #4
maseby
Member
 
Registered: Oct 2003
Posts: 42

Original Poster
Rep: Reputation: 15
tnx.......

great....


thats a way to solve it.....but I am sure there is another way that some how implements the nordic encoding system....


one way or another I will find out....
 
Old 10-26-2003, 05:13 PM   #5
maseby
Member
 
Registered: Oct 2003
Posts: 42

Original Poster
Rep: Reputation: 15
 
  


Reply



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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Python2.4 sanu Linux - Newbie 1 04-01-2005 07:31 AM
Install python2.4 elopee Programming 7 02-01-2005 12:14 PM
python2.2 is not available? darrylneufeld Fedora 4 06-01-2004 08:10 AM
python2 interpreter..... maseby Programming 0 10-23-2003 04:34 PM
python2.2 Dependencies webboss Linux - General 3 03-06-2002 04:20 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:36 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration