851 outputStream.write('\\');
852 writeRawString(keyword);
853 writeRawString(String.valueOf(arg)); /* TODO: correct in all cases? */
854 afterKeyword = true;
855 }
856
857 public void writeBegingroup()
858 throws IOException
859 {
860 outputStream.write('{');
861 afterKeyword = false;
862 }
863
864 public void writeEndgroup()
865 throws IOException
866 {
867 outputStream.write('}');
868 afterKeyword = false;
869 }
870
871 public void writeCharacter(char ch)
872 throws IOException
873 {
874 /* Nonbreaking space is in most RTF encodings, but the keyword is
875 preferable; same goes for tabs */
876 if (ch == 0xA0) { /* nonbreaking space */
877 outputStream.write(0x5C); /* backslash */
878 outputStream.write(0x7E); /* tilde */
879 afterKeyword = false; /* non-alpha keywords are self-terminating */
880 return;
881 }
882
883 if (ch == 0x09) { /* horizontal tab */
884 writeControlWord("tab");
885 return;
886 }
887
888 if (ch == 10 || ch == 13) { /* newline / paragraph */
889 /* ignore CRs, we'll write a paragraph element soon enough */
890 return;
|
851 outputStream.write('\\');
852 writeRawString(keyword);
853 writeRawString(String.valueOf(arg)); /* TODO: correct in all cases? */
854 afterKeyword = true;
855 }
856
857 public void writeBegingroup()
858 throws IOException
859 {
860 outputStream.write('{');
861 afterKeyword = false;
862 }
863
864 public void writeEndgroup()
865 throws IOException
866 {
867 outputStream.write('}');
868 afterKeyword = false;
869 }
870
871 @SuppressWarnings("fallthrough")
872 public void writeCharacter(char ch)
873 throws IOException
874 {
875 /* Nonbreaking space is in most RTF encodings, but the keyword is
876 preferable; same goes for tabs */
877 if (ch == 0xA0) { /* nonbreaking space */
878 outputStream.write(0x5C); /* backslash */
879 outputStream.write(0x7E); /* tilde */
880 afterKeyword = false; /* non-alpha keywords are self-terminating */
881 return;
882 }
883
884 if (ch == 0x09) { /* horizontal tab */
885 writeControlWord("tab");
886 return;
887 }
888
889 if (ch == 10 || ch == 13) { /* newline / paragraph */
890 /* ignore CRs, we'll write a paragraph element soon enough */
891 return;
|