[Vuejs]-Search Turkish Character Problem on VueJs Bootstrap Vue Table

0👍

You can compare Turkish characters using toLocaleUpperCase('tr-TR') like:

const firstWord = 'istanbul';
const secondWord = 'İstanbul';
// If firstWord contains secondWord, firstWordContainsSecondWord will be true otherwise false.
const firstWordContainsSecondWord = firstWord.toLocaleUpperCase('tr-TR').indexOf(secondWord.toLocaleUpperCase('tr-TR')) !== -1; 

Simple example:

new Vue({
  el: '#app',
  data: {
    firstWord: 'istanbul',
    secondWord: 'İstanbul',
    result: null,
  },
  watch: {
    firstWord() {
      this.contains();
    },
    secondWord() {
      this.contains();
    }
  },
  mounted() {
    this.contains();
  },
  methods: {
    contains() {
      // If firstWord contains secondWord, result will be true otherwise false.
      this.result = this.firstWord.toLocaleUpperCase('tr-TR').indexOf(this.secondWord.toLocaleUpperCase('tr-TR')) !== -1;
    }
  }
});
<script src="https://cdn.jsdelivr.net/vue/latest/vue.js"></script>

<div id="app">
  <input placeholder="firstWord" v-model="firstWord">
  <input placeholder="secondWord" v-model="secondWord">
  <br/><br/>
  <div>
    Result =>
    <br/> {{ firstWord }} contains {{ secondWord }} : {{ result }}
  </div>
</div>

Leave a comment