c# - Question Mark ("?") Getting Appended to String -
so writing program , using existing library written else. library making call themoviedatabase.com , retrieving information movie, including youtube trailer name 'serd7y00r_8'.
when debugging , view trailer name string variable value stored in, appears 'serd7y00r_8', when gets inserted database or printed console seems append ? (question mark) end , appears this: 'serd7y00r_8?'
this causing me problems obviously. cannot figure out why doing , how fix it. can guess non regular text character or something, guess.
here link wrapper library: https://github.com/lordmike/tmdblib/
this method call in wrapper library, passing in id 143049:
tmdblib.objects.movies.movie tmdbmovie = client.getmovie(id, moviemethods.credits | moviemethods.keywords | moviemethods.images | moviemethods.trailers | moviemethods.reviews | moviemethods.releases); and here print console after:
console.writeline("'" + tmdbmovie.trailers.youtube[i].source + "'"); .length property returns 12 appears 1 character not show in debugger prints out ? in console
per comment printed out encoding.getbytes details:
encoding entire string: system.text.utf7encoding : 20 38 :73 45 72 44 37 59 30 30 52 2b 41 46 38 2d 38 2b 49 41 34 2d system.text.utf8encoding : 14 39 :73 45 72 44 37 59 30 30 52 5f 38 e2 80 8e system.text.unicodeencoding : 24 26 :73 00 45 00 72 00 44 00 37 00 59 00 30 00 30 00 52 00 5f 00 38 00 0e 20 system.text.unicodeencoding : 24 26 :00 73 00 45 00 72 00 44 00 37 00 59 00 30 00 30 00 52 00 5f 00 38 20 0e system.text.utf32encoding : 48 52 :73 00 00 00 45 00 00 00 72 00 00 00 44 00 00 00 37 00 00 00 59 00 00 00 30 00 00 00 30 00 00 00 52 00 00 00 5f 00 00 00 38 00 00 00 0e 20 00 00 
it seems question mark appears because encoding mismatch , since string should in ascii encoding can remove non-ascii characters resolve mismatch.
to can use regex find non-ascii characters([^\u0000-\u007f]) , replace them empty string:
str=regex.replace(str, @"[^\u0000-\u007f]", string.empty);
Comments
Post a Comment