Unable to count the lenght of String if it contains special character

Hi,
I am working on Mobile Automation for a native mobile app. I have Edit Textbox which contains an IP Address. I am trying to clear that Edit Textbox.

IP: http://111.22.33.444/ABCAndroidTest/MobileService

Approach: I am counting the length of String in the textbox. Then I am clicking KEYCODE_DPAD_RIGHT for the number of length of String. And then I am clicking KEYCODE_DEL for the number of length of String.

 int stringLength = serverURLTextbox.length();
    	    System.out.println(stringLength);
    	    for (int i = 0; i < stringLength; i++) {
    	    	androidDriver.pressKeyCode(22);// "KEYCODE_DPAD_RIGHT"
    	    }
    	
    	    for (int i = 0; i < stringLength; i++) {
    	    	androidDriver.pressKeyCode(67); // "KEYCODE_DEL"
    	    }

The actual count of the String is 49 but printing “stringLength” shows 41.
My guess is that, it is unable to count special character “:” and “/”.
Any Idea to fix this issue?