23a24,27
> :- type windows1251 ---> windows1251.
> 
> :- instance encoding(windows1251).
> 
49c53
<     string__from_char_list(Cs, Str).
---
>     string.from_char_list(Cs, Str).
56c60
<     ( { U > 0x00, U < 0x80, char__to_int(C, U) } ->
---
>     ( { U > 0x00, U < 0x80, char.to_int(C, U) } ->
81c85
<     string__from_char_list(Cs, Str).
---
>     string.from_char_list(Cs, Str).
88c92
<     ( { char__to_int(C, U) } ->
---
>     ( { char.to_int(C, U) } ->
96a101,164
> %%%%=====================================================================
> 
> 
> :- instance encoding(windows1251) where [
> 	pred(decode/4) is decode_windows1251,
> 	pred(encode/3) is encode_windows1251
> ].
> 
> :- pred decode_windows1251(windows1251, unicode, entity, entity).
> :- mode decode_windows1251(in, out, in, out) is semidet.
> decode_windows1251(_, Unicode) -->
>     [CharCode],
>     ( { CharCode /\ 0x80 = 0 } ->
>         { Unicode = CharCode }
>     ; { CharCode = 168 } ->
> 	{ Unicode = 0x401 }
>     ; { CharCode = 184 } ->
> 	{ Unicode = 0x451 }
>     ; { CharCode = 185 } ->
> 	{ Unicode = 0x2116 }
>     ; { CharCode >= 192, CharCode < 256 } ->
> 	{ Unicode = CharCode + 848 }
>     ;
>         %{ error("decode_windows1251: bad value!") }
> 	{ fail }
>     ).
> 
> :- pred encode_windows1251(windows1251, list(unicode), string).
> :- mode encode_windows1251(in, in, out) is det.
> encode_windows1251(_, Us, Str) :-
>     unicodesToWindows1251(Us, Cs, []),
>     string.from_char_list(Cs, Str).
> 
> 
> :- pred unicodesToWindows1251(list(unicode), list(char), list(char)).
> :- mode unicodesToWindows1251(in, out, in) is det.
> unicodesToWindows1251([]) --> [].
> unicodesToWindows1251([U|Us]) -->
>     ( { isASCII(U), char.to_int(C, U) } ->
>     	[C],
> 	unicodesToWindows1251(Us)
>     ; { U >= 0x410, U < 0x450, char.to_int(CyrilChar, U - 848)} ->
>         [CyrilChar],
> 	unicodesToWindows1251(Us)
>     %%  double dot E
>     ; { U = 0x401, char.to_int(Ddot_E, 168)} ->
>         [Ddot_E],
> 	unicodesToWindows1251(Us)
>     %%  double dot e
>     ; { U = 0x451, char.to_int(Ddot_e, 184)} ->
>         [Ddot_e],
> 	unicodesToWindows1251(Us)
>     %%  'No' (Numero)
>     ; { U = 0x2116, char.to_int(No, 185)} ->
>         [No],
> 	unicodesToWindows1251(Us)
>     ;
>         { format("unicodesToWindows1251: couldn't convert U-%x to Windows-1251",
> 		[i(U)], Msg) },
> 	{ error(Msg) }
>     ).
> 
> %%%%=====================================================================
> 
138c206
<     string__from_char_list(Cs, Str).
---
>     string.from_char_list(Cs, Str).
147c215
<         { char__to_int(C, U) }
---
>         { char.to_int(C, U) }
154,155c222,223
<         { char__to_int(C0, U0) },
<         { char__to_int(C1, U1) }
---
>         { char.to_int(C0, U0) },
>         { char.to_int(C1, U1) }
163,165c231,233
<         { char__to_int(C0, U0) },
<         { char__to_int(C1, U1) },
<         { char__to_int(C2, U2) }
---
>         { char.to_int(C0, U0) },
>         { char.to_int(C1, U1) },
>         { char.to_int(C2, U2) }
174,177c242,245
<         { char__to_int(C0, U0) },
<         { char__to_int(C1, U1) },
<         { char__to_int(C2, U2) },
<         { char__to_int(C3, U3) }
---
>         { char.to_int(C0, U0) },
>         { char.to_int(C1, U1) },
>         { char.to_int(C2, U2) },
>         { char.to_int(C3, U3) }
187,191c255,259
<         { char__to_int(C0, U0) },
<         { char__to_int(C1, U1) },
<         { char__to_int(C2, U2) },
<         { char__to_int(C3, U3) },
<         { char__to_int(C4, U4) }
---
>         { char.to_int(C0, U0) },
>         { char.to_int(C1, U1) },
>         { char.to_int(C2, U2) },
>         { char.to_int(C3, U3) },
>         { char.to_int(C4, U4) }
202,207c270,275
<         { char__to_int(C0, U0) },
<         { char__to_int(C1, U1) },
<         { char__to_int(C2, U2) },
<         { char__to_int(C3, U3) },
<         { char__to_int(C4, U4) },
<         { char__to_int(C5, U5) }
---
>         { char.to_int(C0, U0) },
>         { char.to_int(C1, U1) },
>         { char.to_int(C2, U2) },
>         { char.to_int(C3, U3) },
>         { char.to_int(C4, U4) },
>         { char.to_int(C5, U5) }
222,223c290,291
<     string__unsafe_index(E0^text, E0^curr, C),
<     char__to_int(C, U),
---
>     string.unsafe_index(E0^text, E0^curr, C),
>     char.to_int(C, U),
225d292
< 
