Initial commit

This commit is contained in:
github-classroom[bot]
2022-04-28 08:39:46 +00:00
commit 2a34df16f4
47 changed files with 6848 additions and 0 deletions
+50
View File
@@ -0,0 +1,50 @@
/*
* Gradle build configuration for specific lab module / exercise
*/
// enabled plugins
plugins {
id 'java'
// Apply the application plugin to add support for building a CLI application.
id 'application'
}
// Project/Module information
description = 'Lab05 UnderstandingCharsets'
group = 'ch.zhaw.prog2'
version = '2022.1'
// Dependency configuration
repositories {
mavenCentral()
}
dependencies {
}
// Configuration for Application plugin
application {
// Define the main class for the application.
mainClass = 'ch.zhaw.prog2.io.UnderstandingCharsets'
}
// enable console input when running with gradle
run {
standardInput = System.in
}
// Java plugin configuration
java {
// By default the Java version of the gradle process is used as source/target version.
// This can be overridden, to ensure a specific version. Enable only if required.
// sourceCompatibility = JavaVersion.VERSION_17 // ensure Java source code compatibility
// targetCompatibility = JavaVersion.VERSION_17 // version of the created byte-code
// Java compiler specific options
compileJava {
// source files should be UTF-8 encoded
options.encoding = 'UTF-8'
// for more options see https://docs.gradle.org/current/dsl/org.gradle.api.tasks.compile.CompileOptions.html
}
}
@@ -0,0 +1,48 @@
package ch.zhaw.prog2.io;
import java.io.*;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
public class UnderstandingCharsets {
public static void main(String[] args) {
/* Teilaufgabe a
* In der Vorlesung haben Sie gelernt, dass Java-Klassen fuer Unicode entworfen wurden.
* Nun ist Unicode aber nicht der einzige Zeichensatz und Java unterstuetz durchaus Alternativen.
* Welche Zeichensaetze auf einem System konkret unterstuetzt werden haengt von der Konfiguration des Betriebssystems JVM ab.
* Schreiben Sie ein Programm, welches alle Unterstuetzten Zeichensaetze auf der Konsole (System.out) ausgibt,
* zusammen mit dem Standardzeichensatz.
* https://docs.oracle.com/javase/8/docs/api/java/nio/charset/Charset.html
*/
// ToDo: Print default character set
// Todo: Print all available character sets
/* Ende Teilaufgabe a */
/* Teilaufgabe b
* Ergänzen Sie die Klasse so, dass sie einzelne Zeichen (also Zeichen für Zeichen) im Standardzeichensatz
* von der Konsole einliest und in zwei Dateien schreibt einmal im Standardzeichensatz und einmal im
* Zeichensatz `US-ASCII`.
* Die Eingabe des Zeichens `q` soll das Program ordentlich beenden.
* Die Dateien sollen `CharSetEvaluation_Default.txt` und `CharSetEvaluation_ASCII.txt` genannt und
* werden entweder erzeugt oder, falls sie bereits existieren, geöffnet und der Inhalt überschrieben.
* Testen Sie Ihr Program mit den folgenden Zeichen: a B c d € f ü _ q
* Öffnen Sie die Textdateien nach Ausführung des Programs mit einem Texteditor und erklären Sie das Ergebnis.
* Öffnen Sie die Dateien anschliessend mit einem HEX-Editor und vergleichen Sie.
*/
}
}