Difference between revisions of "Character encoding"
(→checks 1) |
|||
Line 1: | Line 1: | ||
− | Character encoding levert bij de uitwisseling tussen verschillende systemen problemen op. Linux, AIX en Sun Solaris gedragen zich anders. |
+ | Character encoding levert bij de uitwisseling tussen verschillende systemen problemen op. Linux, AIX en Sun Solaris gedragen zich anders.</br> |
+ | De commando's file en enca |
||
= checks 1 = |
= checks 1 = |
||
So if I compile this, we can check. |
So if I compile this, we can check. |
Revision as of 16:32, 23 October 2012
Character encoding levert bij de uitwisseling tussen verschillende systemen problemen op. Linux, AIX en Sun Solaris gedragen zich anders.
De commando's file en enca
Contents
checks 1
So if I compile this, we can check.
public class CharSetTest { public static void main(String[] args) { System.out.println("Default Charset=" + Charset.defaultCharset()); System.setProperty("file.encoding", "Latin-1"); System.out.println("file.encoding=" + System.getProperty("file.encoding")); System.out.println("Default Charset=" + Charset.defaultCharset()); System.out.println("Default Charset in Use=" + getDefaultCharSet()); } private static String getDefaultCharSet() { OutputStreamWriter writer = new OutputStreamWriter(new ByteArrayOutputStream()); String enc = writer.getEncoding(); return enc; } }
check 2
try this simple program import java.io.FileWriter; import java.io.IOException; public class Test { public static void main(String args[]) throws IOException { FileWriter filewrt = new FileWriter("out"); String defaultcharset = filewrt.getEncoding(); filewrt.close(); System.out.println("Default encoding is :" + defaultcharset); } }
check 3
import java.io.FileWriter; import java.io.IOException; import java.util.Locale; public class Test { public static void main(String args[]) throws IOException { FileWriter filewrt = new FileWriter("out"); String defaultcharset = filewrt.getEncoding(); filewrt.close(); System.out.println("Default encoding is :" + defaultcharset); Locale locale = Locale.getDefault(); System.out.println(locale); } }
check 4
this is teh program that i run on test import java.io.BufferedWriter; import java.io.FileWriter; public class FileWrite { public static void main(String args[]) { try { // Create file FileWriter fstream = new FileWriter("out.txt"); BufferedWriter out = new BufferedWriter(fstream); out.write("Damásio Pinto Do Carmo"); // Close the output stream out.close(); } catch (Exception e) {// Catch exception if any System.err.println("Error: " + e.getMessage()); } } }