strings.xml 파일에 SQL 쿼리를 저장해 두고, 코드에서 String.Format으로 최종 문자열을 만들려고 해요. SELECT 쿼리에는 이런 like 절이 들어 있어요:
SELECT ColumnA, ColumnB FROM records WHERE ColumnA LIKE '%pattern%'
서식을 적용하려고 'pattern'을 %1$s로 바꾸니 이렇게 됩니다:
SELECT ColumnA, ColumnB FROM records WHERE ColumnA LIKE \'%%1$s%\'
작은따옴표는 백슬래시로 이스케이프할 수 있어요. 그런데 % 문자는 아직 이스케이프하지 못했어요.
strings.xml에 like 절을 넣으려면 어떻게 하나요?
영어에서 번역·원문 보기My strings.xml file holds a SQL query, and I'm trying to construct the finished string in code with String.Format. The SELECT query contains a like clause along these lines:
SELECT ColumnA, ColumnB FROM records WHERE ColumnA LIKE '%pattern%'
For formatting, I substitute %1$s for 'pattern', giving me:
SELECT ColumnA, ColumnB FROM records WHERE ColumnA LIKE \'%%1$s%\'
Backslashes let me escape the single quotes. The % character, however, is something I haven't managed to escape.
What is the way to put a like clause into strings.xml?