code: public static void setChar (@Nonnull final CharSequence aSeq, final int nIndex, final int nCodepoint)
    {
      if (!(aSeq instanceof StringBuilder) && !(aSeq instanceof StringBuffer))
      {
        setChar (new StringBuilder (aSeq), nIndex, nCodepoint);
      }
      else
      {
        int l = 1;
        int nI = nIndex;
        final char ch = aSeq.charAt (nI);
        final boolean high = Character.isHighSurrogate (ch);
        final boolean low = Character.isLowSurrogate (ch);
        if (high || low)
        {
          if (high && (nI + 1) < aSeq.length () && Character.isLowSurrogate (aSeq.charAt (nI + 1)))
            l++;
          else
          {
            if (low && nI > 0 && Character.isHighSurrogate (aSeq.charAt (nI - 1)))
            {
              nI--;
              l++;
            }
          }
        }
        if (aSeq instanceof StringBuffer)
          ((StringBuffer) aSeq).replace (nI, nI + l, getAsString (nCodepoint));
        else
          ((StringBuilder) aSeq).replace (nI, nI + l, getAsString (nCodepoint));
      }
    }
docs: Set the character at a given location, automatically dealing with surrogate
  pairs
  
  @param aSeq
  source sequence
  @param nIndex
  index
  @param nCodepoint
  codepoint to be set