Skip to content

Instantly share code, notes, and snippets.

@Guiorgy
Last active January 31, 2024 13:27
Show Gist options
  • Select an option

  • Save Guiorgy/1367f7d10c553f55d2c4429ebefaa550 to your computer and use it in GitHub Desktop.

Select an option

Save Guiorgy/1367f7d10c553f55d2c4429ebefaa550 to your computer and use it in GitHub Desktop.
Create an SQL function that converts ASCII characters to Georgian. (Useful for storing Georgian strings in the database using the ASCII encoding to save space and improve compatibility)
CREATE FUNCTION [dbo].[ASCII_TO_GEORGIAN] (@ascii nvarchar(max))
RETURNS NVARCHAR(MAX)
AS
BEGIN
DECLARE @ret NVARCHAR(max);
SET @ret =
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(@ascii COLLATE SQL_Latin1_General_CP1_CS_AS, N'a', N'ა')
, N'b', N'ბ')
, N'g', N'გ')
, N'd', N'დ')
, N'e', N'ე')
, N'v', N'ვ')
, N'z', N'ზ')
, N'T', N'თ')
, N'i', N'ი')
, N'k', N'კ')
, N'l', N'ლ')
, N'm', N'მ')
, N'n', N'ნ')
, N'o', N'ო')
, N'p', N'პ')
, N'J', N'ჟ')
, N'r', N'რ')
, N's', N'ს')
, N't', N'ტ')
, N'u', N'უ')
, N'f', N'ფ')
, N'q', N'ქ')
, N'R', N'ღ')
, N'y', N'ყ')
, N'S', N'შ')
, N'C', N'ჩ')
, N'c', N'ც')
, N'Z', N'ძ')
, N'w', N'წ')
, N'W', N'ჭ')
, N'x', N'ხ')
, N'j', N'ჯ')
, N'h', N'ჰ');
RETURN @ret;
END;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment