Marek Grác
Marek Grác

Reputation: 773

The difference between Android's String.includes() and String.startsWith()

I have found a very strange scenario that I can't understant. Let's have a code (React Native 0.43) that does not work on Android 7 (both emulator and real device).

const name = 'Medvěd kamčatský';

const t1 = name.startsWith('M'); // -> false
const t2 = name.includes('M'); // -> true

If I will remove accents from name both of the variables are true. Both of them are true on iOS as well. Is there a right approach how to handle such issues (or am I doing something wrong) ?

Upvotes: 1

Views: 262

Answers (1)

MattyK14
MattyK14

Reputation: 2126

There's an issue with startsWith on Android. Worked fine in debug on simulator but in production on a real device it wasn't returning the expected output for me. You might be experiencing said issue: #11370

Upvotes: 1

Related Questions