Good day. There is a task to convert the names of cities written in Cyrillic into HEX format, but it is necessary to convert as much as microsoft wants. Then, using the created hexes, I will create qds files for searching in AD. There is such a code

$a = "Хабаровск"; $b = $a.ToCharArray(); Foreach ($element in $b) {$c = $c + [System.String]::Format("{0:X}" + "0", [System.Convert]::ToUInt32($element))} $c 

But it gives 4250430043104300440043E04320441043A0 such value. And if I save the search request in AD in the qds file, then there is a value in the place where the city name is 250430043104300440043E04320441043A04000005 , at the end of the zeroes there is a cheksumma that is understandable. It seems to be the same, but what is the 4th at first, is the hex from the length of the string coming, what? at the end comes the hex from stringlenght+1 . Has anyone encountered such a task? I apologize if it is weakly stable, even I don’t catch up with how to edit it normally

  • Unicode text, Russian in UTF-16 with the second byte is 0x04. In the first line, something went wrong. The second looks more or less valid, with a terminator and a magical 5. - 0andriy
  • Aah, you have some 4 from the end to the beginning moved. Yes, 36 characters on nine letters ... - 0andriy
  • Well, with 4 figured out, according to the result, I just threw it at the end with her replace. I don’t understand one thing now, in 250430043104300440043E04320441043A04000005, 5 is a hash cheksumma, but what is 00000 before this five, for the word Khabarovsk, it turns out 5 zeros, if I write Moscow then 4 zeros. When hashing the names of cities, there are no zeros at the end, I add them by concatenation, similar to how Windows stores. Only on what the number of these zeros depends, I take a three-character city, I get 4 zeros, I take 8 characters 4, I take 9 -4, only in Khabarovsk I get 5 for some reason. and I write "Khabarovsk", the pancake 4 zero is obtained - Dldmyt
  • Null terminator obviously. - 0andriy
  • @SergeyTeplyakov, Sergey, can you explain the phenomenon? - 0andriy

0