This tenancy of OO to focus on methods instead data is why getters enter the picture because OO places more value on methods for their flexibility. For example String.getBytes must violate encapsulation right? It's exposing the String's implementation detail right? Well not exactly. I could implement a String with a char array and dynamically transform that to a byte array when getBytes method to provide the String is various encodings (ie UTF-8, UTF-16, etc) iswhen it's called. If you didn't have a method that returned you the byte array and you needed it. Then you'd have to get the underlying char array in the string in order to write that method outside of the String object. That would most definitely violate encapsulation.
And that's the thing about this that is tricky. If your requirements demand you have knowledge about character encodings of a String the best way to handle that is to delegate that conversion to the owner of that data to perform the operation for you. That's how OO and encapsulation helps you. By calling that getBytes method you are codifying that as a requirement in your program. OO and encapsulation doesn't let you transcend the requirements.
In fact I will even go another step and say that if you have getters/setters on your object you are practicing encapsulation. And YES even if you return the internal guts of your implementation through a getter! Controversial stance I know, but hear me out. Because you've used a method in order to reveal potential internal workings of a class to the client you haven't prevented yourself into changing those internals later. That's the core test of encapsulation. If you allowed direct access to the instance variables you'd have violated encapsulation and thereby locked yourself into not being able to refactor it. But if you use a getter you can always change the object's internal representation and simply change your getter method without affecting clients. And that is the point of encapsulation. Now you are locked into providing that method (until all clients are changed), but you are still insulating your ability to change from clients.