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