File reading issues in Nokia Asha 303 - java-me

I am reading a fixed number of characters from a file. The file contains both english and arabic text. I have two devices Nokia X3-02 and Nokia Asha 303 for testing. On Nokia X3-02, I am getting the correct string that I require from the file in every case. But on Asha 303, I do not get the complete string when the string contains some arabic character.
I have also tested my code on the sun emulator and it is working fine on it too. The issue seams to be with Nokia Asha 303 device only.
My code is a very simple one in which I read a file by specifying the reading position (Offset) and the length to be read. Please help me as I do not understand this problem.

I have managed to solve the issue. On Nokia x3-02 the app was reading the exact number of characters as specified in the read function of InputStreamReader but on Nokia Asha 303, the characters read were always less than the ones specified. So I had to loop the read function in order to read all characters. Now it is working on Nokia Asha 303.

Related

Translating text in Microsoft translator removes //

I am trying to translate a code file and I see the below issues with Microsoft translator
Translating below text
// 行番号削除正常終
Gives output
Line number deletion successful end
where it removes the //(double slash)
Translating below text
System.out.println("【○】COBOL
Gives output
System.out.println_○○ COBOL
Where the special characters are removed and replaced with some other.
I am reading my file using CP932 encoding and writing using UTF-8.
Please let me know if there are any ideas on how to resolve this issue.
I have tried Google translate and it works well on the same encodings.

C# audio directory issue

Alright, I'm developing a speech recognition system which is working completely fine, I've had no problems with it up until now. And yes i did google search it and look to see if the question had already been answered, but nothing turned up.
What I did was save some text-to-speech lines and put them into the program, it worked fine up until about the 5th audio file, I ran it to try and test if it worked and the program crashed with this error:
NotSupportedException: The given path's format is not supported
which is weird because for every other audio file it worked, the code looks like this :
System.Media.SoundPlayer player8 = new System.Media.SoundPlayer(#"‪C:\Users\user\Desktop\JMAS LINE\15.wav");player8.Play();
It's strange because only specific ones work and don't work
Any help would be appreciated

How to convert Linux Python 3.4 code with national characters into executable code in windows

My national language is Polish.
I've got program in Python 3.4 which I wrote on linux. This program mostly work on text, Polish text. So of course, variable names don't have any special characters, but sometimes I put into them some strings with Polish characters, user will input from keyboard some strings with Polish characters and My program read from files, where I got strings with Polish characters.
Everything work well on Linux. I didn't think about encoding, it just worked. But now i want to make it work on Windows. Can you help me understand, what I should actually do to make this transform?
Or maybe some workaround - I just need to have Windows executable file. Perfect way for this, would be "Pyinstaller", but it work only for python 2.7, not 3.4. That's why I want to make it working on Windows, and in VirtualBox with py2exe compile into executable form. But maybe somone know way for this in Linux, it without this encoding problems, it would be great.
If not, I back to my question. I tried to convert my python scripts in gedit into ISO or CP1250 or 1252, I wrote in the file headline what coding I'm using, it actually worked a little, now my windows error pint me into my files with text form which I read some data, so I converted them too... But it didn't work.
So I decided, that it's no more time for blind trials, and I need to ask for help, I need to understand what encoding is used on windows, which on linux, what is the best way to convert one into another, and how make program read characters in right way.
The best way would be - I guess - not changing anything in encoding, but just make windows python understand what encoding I'm using. Is that possible?
Complete answer for my question would be great, but anything what will point me in right direction will also help me a lot.
OK. I'm not sure, if I understand your answer in comments, but tried sending text for myself via mail, coping it in virtualbox into notepad and save as utf_8. Still get this message:
C:\Users\python\Documents>py pytania.py
Traceback (most recent call last):
File "pytania.py", line 864, in <module>
start_probny()
File "pytania.py", line 850, in start_probny
utworzenie_danych()
File "pytania.py", line 740, in utworzenie_danych
utworzenie_pytania_piwo('a')
File "pytania.py", line 367, in utworzenie_pytania_piwo
for line in f: # Czytam po jednej linii
File "C:\Python34\lib\encodings\cp1252.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 1134: cha
racter maps to <undefined>
As mentioned by Zero Piraeus in a comment: The default source encoding for Python 3.x is UTF-8, regardless of what platform it's running on...
If you have problems, that probably because your source code has incorrect encoding. You should stick to UTF-8 only (even though PEP 0263 -- Defining Python Source Code Encodings allows changing it).
The error message you provided is clear:
UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 1134
Python is currently expecting UTF8 (because "UnicodeDecodeError"!), but it encounters an illegal char (0x9d isn't a valid char is UTF8). To diagnose the problem, use iconv(1) on a Linux machine, to detect errors buy doing a dummy conversion:
iconv -f utf8 -t iso8859-2 -o /dev/null < test.py
You can try to reproduce the problem by creating a very simple python file, typically : print "test €uro encoding"

I use UTF-16LE when I parsing xml. But, it does not work on some device

Device is getting a UTF16 encoded XML response then I parse xml.
On some device it doesn't work. All these devices support utf-16.
What may be the problem in?
It's tricky without seeing code, but if I remember correctly, some nokia devices were choosy about whether you used a hyphen or not in the encoding name. If "UTF16" doesn't work, try "UTF-16" instead, or vise versa.

iPhone App Dev - Edited mp3 files are not working in App

In my application there are mp3 files located in the bundle (nothing from the web). Some of the mp3 files are original files and some I had edited using simple sound editing software (the ones where you insert a file, cut a slice of it and save it as a new and shorter mp3 file).
I'm using the AVAudioPlayer [initWithData] method.
All the original files (the ones that I hadn't edited and inserted to the bundle as is) are working perfectly and all the ones that were edited are not working at all.
I used 2 different editing software and the outcome is the same.
Anyone had ever encountered that or have any idea what may I done wrong?
Thanks,
Ohad
Converting the mp3 to caf worked for me
as specified here.
see the following:
How do I convert an audio file to the preferred format for iPhone OS?
The preferred full-quality audio format for iPhone OS is 16-bit, little-endian, linear PCM packaged as a CAF file. To convert an audio file to this format, use the afconvert tool at the command line in Mac OS X, as shown in Listing 5.
Listing 5 Converting an audio file to the preferred format for iPhone OS
/usr/bin/afconvert -f caff -d LEI16 {INPUT} {OUTPUT}
To see all the options available for the afconvert tool, enter afconvert -h at the command line.

Resources