129{
132
133 const EntitySpecial* pEntity =
NULL;
134 const wchar_t* pStart = _str.data();
135 const wchar_t* pCurrent = pStart;
136
137 while(*pCurrent) {
138 switch(*pCurrent) {
139 case L'\t' :
140 if (pStart < pCurrent)
141 r.append(pStart, pCurrent - pStart);
142
143 if (_tab2Space > 0) {
144
145 int nSpace = _tab2Space;
146 while(*(++pCurrent)) {
147 if (*pCurrent == L' ')
148 nSpace++;
149 else if (*pCurrent == L'\t')
150 nSpace += _tab2Space;
151 else
152 break;
153 }
154 r += __GetSpace(nSpace);
155 pStart = pCurrent;
156 }
157 else {
158
160 pStart = ++pCurrent;
161 }
162 break;
163 case ' ' :
164 if (pStart < pCurrent)
165 r.append(pStart, pCurrent - pStart);
166
167 if (_tab2Space > 0) {
168 int nSpace = 1;
169 while(*(++pCurrent)) {
170 if (*pCurrent == L' ')
171 nSpace++;
172 else if (*pCurrent == L'\t')
173 nSpace += _tab2Space;
174 else
175 break;
176 }
177 r += __GetSpace(nSpace);
178 pStart = pCurrent;
179 }
180 else {
181 int nSpace = 1;
182 while(*(++pCurrent) == L' ')
183 nSpace++;
184 r += __GetSpace(nSpace);
185 pStart = pCurrent;
186 }
187 break;
188 case '\r' :
189 if (pStart < pCurrent)
190 r.append(pStart, pCurrent - pStart);
191
192 pStart = ++pCurrent;
193 break;
194 case '\n' :
195 if (pStart < pCurrent)
196 r.append(pStart, pCurrent - pStart);
198 r.append(L
"\r\n", 2);
200 pStart = ++pCurrent;
201 break;
202 default :
203 if (__exists(L"<>&", *pCurrent)
204 && (pEntity = __special(*pCurrent))) {
205
206 if (pStart < pCurrent)
207 r.append(pStart, pCurrent - pStart);
208 r.append(pEntity->
psz, pEntity->
n);
209 pStart = ++pCurrent;
210 }
211 else
212 ++pCurrent;
213 }
214 }
215
216 if (pStart < pCurrent)
217 r.append(pStart, pCurrent - pStart);
218
220
221
222
223
224
225
226
227
229}