title: Detect keyboard combinations that change text
body: <p>I have a library I’m building that needs to keep track of text entry into a UITextView in order to keep track of positions of certain sections of text. Most cases are handled fine within the <code>textView(_:shouldChangeTextIn:replacementText:)</code> method. The problem I’m having is that certain keyboards have character combinations that will actually change the character without calling the <code>textView(_:shouldChangeTextIn:replacementText:)</code> method. A simple example of this is if you choose a Vietnamese keyboard and type <code>uw</code> it will change to <code>ú</code> but the only calls to <code>textView(_:shouldChangeTextIn:replacementText:)</code> will be for the entry of u and w. The offset calculations will be incorrect at this point. As far as I can tell there’s no other method that I could use to know about this change. I’m not sure if this is a bug or not. The textViewDidChange method will be called but I was hoping to avoid hacky logic where I compare the previous and new text of the textView to determine any changes and adjust logic there. If anyone has suggestions I would love to hear them. Hopefully someone has seen and solved this problem. Thanks. </p>
  
  <p>To clarify, I need to handle this situation using something other than subclassing. </p>
  
  <p>Sample project: <a href="https://github.com/szweier/ShouldChangeTextInRange" rel="nofollow noreferrer">https://github.com/szweier/ShouldChangeTextInRange</a>
  If you run the code above and choose the Vietnamese keyboard to type in <code>uw</code> you will see that the string generated in the <code>textView(_:shouldChangeTextIn:replacementText:)</code> method will be different from the text within the textView.</p>