--- /dev/null
+package org.bouncycastle.asn1;
+
+import java.io.*;
+
+/**
+ * DER PrintableString object.
+ */
+public class DERPrintableString
+ extends DERObject
+ implements DERString
+{
+ String string;
+
+ /**
+ * basic constructor - byte encoded string.
+ */
+ public DERPrintableString(
+ byte[] string)
+ {
+ try
+ {
+ this.string = new String(string, "US-ASCII");
+ }
+ catch(UnsupportedEncodingException e)
+ {
+ throw new RuntimeException("PANIC: " + e);
+ }
+ }
+
+ /**
+ * basic constructor
+ */
+ public DERPrintableString(
+ String string)
+ {
+ this.string = string;
+ }
+
+ public String getString()
+ {
+ return string;
+ }
+
+ public byte[] getOctets()
+ {
+ try
+ {
+ return string.getBytes("US-ASCII");
+ }
+ catch(UnsupportedEncodingException e)
+ {
+ throw new RuntimeException("PANIC: " + e);
+ }
+ }
+
+ void encode(
+ DEROutputStream out)
+ throws IOException
+ {
+ out.writeEncoded(PRINTABLE_STRING, this.getOctets());
+ }
+}