code: private static String doWriteForward(String src, int options) {
          /* optimize for several combinations of options */
          switch(options&(Bidi.REMOVE_BIDI_CONTROLS|Bidi.DO_MIRRORING)) {
          case 0: {
              /* simply return the LTR run */
              return src;
          }
          case Bidi.DO_MIRRORING: {
              StringBuffer dest = new StringBuffer(src.length());
  
              /* do mirroring */
              int i=0;
              int c;
  
              do {
                  c = UTF16.charAt(src, i);
                  i += UTF16.getCharCount(c);
                  UTF16.append(dest, UCharacter.getMirror(c));
              } while(i < src.length());
              return dest.toString();
          }
          case Bidi.REMOVE_BIDI_CONTROLS: {
              StringBuilder dest = new StringBuilder(src.length());
  
              /* copy the LTR run and remove any Bidi control characters */
              int i = 0;
              char c;
              do {
                  c = src.charAt(i++);
                  if(!Bidi.IsBidiControlChar(c)) {
                      dest.append(c);
                  }
              } while(i < src.length());
              return dest.toString();
          }
          default: {
              StringBuffer dest = new StringBuffer(src.length());
  
              /* remove Bidi control characters and do mirroring */
              int i = 0;
              int c;
              do {
                  c = UTF16.charAt(src, i);
                  i += UTF16.getCharCount(c);
                  if(!Bidi.IsBidiControlChar(c)) {
                      UTF16.append(dest, UCharacter.getMirror(c));
                  }
              } while(i < src.length());
              return dest.toString();
          }
          } /* end of switch */
      }
docs: /*
  When we have OUTPUT_REVERSE set on writeReordered(), then we
  semantically write RTL runs in reverse and later reverse them again.
  Instead, we actually write them in forward order to begin with.
  However, if the RTL run was to be mirrored, we need to mirror here now
  since the implicit second reversal must not do it.
  It looks strange to do mirroring in LTR output, but it is only because
  we are writing RTL output in reverse.