[android-developers] Re: Writing files in UTF-8

2012-03-30 Thread Remote Red
 But the question marks in the in the file i attached are because google
 groups did not get it right the document... Locally it works and I can send
 it through mail without issues.

Sorry but I find it hard to believe that when Google offers us a
platform to discuss development and offers the possibility to upload
files so we can show them others that those files are changed and
corrupted.

A giant as Google would never do that

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Writing files in UTF-8

2012-03-30 Thread Remote Red
 .put(0, (byte) 0xEF)
 .put(1, (byte) 0xBB)
 .put(2, (byte) 0xBF)

 However when the file is created and I open it with either notepad++ or
 excel the first characters are  not show, the file always starts with *
 artdate* .

 Any idea how to work around this?

You are using put(). Those three statements will overwrite the
first three bytes.

Isn't there an insert() ?

If not: just first write the bom and then the bytes.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Writing files in UTF-8

2012-03-30 Thread Remote Red
Looping?

byte[] bom = {(byte)0xEF, (byte)0xBB, (byte)0xBF };
byte[] byteResult =
Charset.forName(UTF-8).encode(result.toString()).array();

fos = new FileOutputStream(file);
fos.write(bom);
fos.write(byteResult);

Doesn't this work?

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Writing files in UTF-8

2012-03-29 Thread Remote Red



     out = new BufferedWriter(new OutputStreamWriter(
 new FileOutputStream(file), UTF-8
     ));

Why are you using FileOutputStream AND OutputStreamWriter AND
BufferedWriter?

     out.write(result.toString());

What is the type of result? How did you put content in it?

You are not checking the returnvalue of your write statement.

 I indeed see that the text is not correct.

Please explain exactly what is wrong with it.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Writing files in UTF-8

2012-03-29 Thread Remote Red


On 29 mrt, 13:03, Dirk Vranckaert dirkvrancka...@gmail.com wrote:
  Why are you using FileOutputStream AND OutputStreamWriter AND
  BufferedWriter?

 I need the OutputStreamWriter to specify the encoding,

Ok. But then why also a BufferedWriter?

 The result is a CSV file,

Sorry but you did not understand my question. You wrote
result.toString()
so of what type is result in result.toString()?

 So when I do so for Dutch, German, English, Frensh,... (all western
 languages) it works.

Do characters like ö, é come through ok?

 ... You can open the CSV file
 in a text-editor


Are you shure you use an utf-8 capable editor?

 So instead of seeing something like this:
 這是一個測試
 I see something like this:
 â €å”€å”€å”€à €à €à €ç¼€ç¼€ç¼€ç¼€ç¼€ç¼€ç¼€Ì€Ì€Ì€Ì€Ì€Ì€

That looks like what an editor that cannot handle utf-8 would display.

All this encoding is very interesting and I would like to help you.

Suggesting:
-make a small utf-8 file with those Chinese characters.
-put that file somewhere on the internet so we can download it.
-make an activity that just reads the file in a string and writes
 the contents of that string to another file.
-compare the two files.

If you publish your activity code here (keep it as small as possible)
I will experiment with it.


-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Writing files in UTF-8

2012-03-29 Thread Remote Red
Just a thougth: does the produced file have a BOM (Byte Order Mark)
as the first bytes?

If not you have to write them yourself.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Writing files in UTF-8

2012-03-29 Thread Remote Red
 I've added out.write('\ufeff'); to write the Byte Order Mark

That is not the bom for utf-8. You wrote the bom for UTF-16.

http://en.wikipedia.org/wiki/Byte_order_mark

The bom for utf-8 is 0xEF, 0xBB, 0xBF.

 ... and you can
 see in the attachment the export now works fine! :)

Those attachment have no bom and do not contain characters like
€å”€å”€å”€à €à €à €ç¼€ç¼€ç¼€ç¼€ç¼€ç¼€ç¼€Ì€Ì€Ì€Ì€Ì€Ì€
but a lot of questionmarks line.
?

You are not done before it works with the right bom.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Tablet Acer Iconica A100 and Environment.getExternalStorageDirectory();

2012-03-13 Thread Remote Red
On 12 mrt, 15:06, Mark Murphy mmur...@commonsware.com wrote:

 Correct, but that is the portion of on-board flash that Acer
 designated as external storage.

Very strange that this is possible. My understanding of external was/
is that that would be the sdCard. But maybe b0b points out how I have
to see it.

All thanks for the reply.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Tablet Acer Iconica A100 and Environment.getExternalStorageDirectory();

2012-03-13 Thread Remote Red
On 12 mrt, 15:06, Mark Murphy mmur...@commonsware.com wrote:

 Bear in mind that your app may not have rights to write to this mount point.

That would be realy silly as it is my tablet and my sdcard. What else
would I do with a sdcard like reading and writing?

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Tablet Acer Iconica A100 and Environment.getExternalStorageDirectory();

2012-03-13 Thread Remote Red
On 13 mrt, 12:24, Mark Murphy mmur...@commonsware.com wrote:
 The firmware may have rights that SDK applications do not.

As I'm quite new to Android programming I had not even tested this.

Fear enclosed my mood.

Luckily my app can write to the microSD card.

Now I don't have to throw it out the window! ;-).

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Tablet Acer Iconica A100 and Environment.getExternalStorageDirectory();

2012-03-12 Thread Remote Red
The tablet Acer Iconica A100 returns for
Environment.getExternalStorageDirectory()

/mnt/sdcard

Actually that is intern memory as the microSD card is mounted as

/mnt/external_sd

I would like my app to find the microSD card.

What are my options?

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: How to format a String in an email so Outlook will print the line breaks?

2012-03-06 Thread Remote Red
Did you try \r\n already?

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Android how to send the hex code out?

2012-03-06 Thread Remote Red
0xfa?

If you tell me how you send out the f and the a then I tell you how to
do that with the 0 and the x. ;-).

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: How to format a String in an email so Outlook will print the line breaks?

2012-03-06 Thread Remote Red
So if you read that mail with a real mail reader -like Thunderbird-
all is ok?

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: HOw to extract only number

2012-03-06 Thread Remote Red
   str=txt.getText().toString();
   int space1=str.indexOf( );
   if ( space1  0 )
s=str.substring(0, space1);
   else
s= str;

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: HTTP POST to Web Server running on Android Device

2012-03-04 Thread Remote Red

 line=POST / HTTP/1.1
 line=Content-Length: 23

No you would see:

line=POST / HTTP/1.1
line=Content-Length: 23
line=0

if a null was returned.

But a null is never returned. Still your
loop ends as instead an exception is trown.

You did not see that because the catch does nothing.
Add a Log.i there and you will see.

You modified the original code which checked for an empty line.
Take the original code again.

Add a check for the Content-Lengh: line and decode the contentlength.
(in your example 23)

Then outside the loop do something like:

[code]
if ( contentlength  0 ){

char [] buffer = new char[contentlength];

int nread = in.read (buffer, 0, contentlength);

String Parameters = new String( buffer);

 // well you should check nread == contentlength
}
[/code]


 I am wondering where the HTTP POST data is?

That just follows the empty line. But as that data is not ended with
a newline in.readLine() cannot be used.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: HTTP POST to Web Server running on Android Device

2012-03-04 Thread Remote Red
 line=POST / HTTP/1.1
 line=Content-Length: 23

No, you would see:
line=POST / HTTP/1.1
line=Content-Length: 23
line=0

if a null was returned. But a null is never returned.

Still your loop ends as instead an exception is trown
which you did not see because the catch statement is empty.
Add a Log.i there and you will see.

You modified the original code where the loops ends
at the first empty line. Take the original code again
en check for the Content-Length line. Parse out
the value for contentlength;

After the loop add following code
[code]
if ( contentlength  0 ) {
char [] buffer = new char[contentlength];


int nread = in.read (buffer, 0, contentlength);

String Parameters = new String( buffer);

// well you should check if nread equals contentlength
}
[/code]


 I am wondering where the HTTP POST data is?

That just follows the empty line. But as this post data is
not terminated with a newline character in.readLine() cannot
be used.


-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: HTTP POST to Web Server running on Android Device

2012-03-04 Thread Remote Red
 line=POST / HTTP/1.1
 line=Content-Length: 23

No, you would see:
line=POST / HTTP/1.1
line=Content-Length: 23
line=0

if a null was returned. But a null is never returned.

Still your loop ends as instead an exception is trown
which you did not see because the catch statement is empty.
Add a Log.i there and you will see.

You modified the original code where the loops ends
at the first empty line. Take the original code again
en check for the Content-Length line. Parse out
the value for contentlength;

After the loop add following code

if ( contentlength  0 ) {
char [] buffer = new char[contentlength];


int nread = in.read (buffer, 0, contentlength);

String Parameters = new String( buffer);

// well you should check if nread equals contentlength
}



 I am wondering where the HTTP POST data is?

That just follows the empty line. But as this post data is
not terminated with a newline character in.readLine() cannot
be used.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en