FoxPro/Visual FoxPro - Conversión de archivo UTF-8 Con la función STRCONV

 
Vista:
sin imagen de perfil
Val: 6
Ha aumentado su posición en 10 puestos en FoxPro/Visual FoxPro (en relación al último mes)
Gráfica de FoxPro/Visual FoxPro

Conversión de archivo UTF-8 Con la función STRCONV

Publicado por MARIA O (9 intervenciones) el 05/03/2020 19:47:00
Buenas tardes comunidad:

Tengo un programa realizado hace bastante tiempo En visual foxpro 9, y estoy generando la factura electrónica, utilice para ello TEXT y ENDTEX, para convertir el archivo a UTF-8 utilizo la función STRCONV, ejemplo

1
2
YlcText=STRCONV(lcText, 9,1034)
=STRTOFILE(YlcText,Lnumfactu,.T.)

Todo esto me funciona, pero cuando pero en la validación para importar el archivo a la DIAN, me sale un error y es en una tilde. Este es el código del archivo que utilizo para generar el XML.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
LOCAL Lnumfactu
Lnumfactu ='c:\Factura _electronica\'+'factura'+ALLTRIM(This.pid)+'.xml'
**--Verifica si el archivo existe lo elimina
DELETE FILE 'c:\Factura _electronica\'+'factura'+ALLTRIM(This.pid)+'.xml'
 
SET TEXTMERGE ON
lcText=""
YlcText=""
 
TEXT TO lcText ADDITIVE TEXTMERGE NOSHOW PRETEXT 4
<?xml version="1.0" encoding="UTF-8"?>
<Invoice>
	<IssueDate><<This.IssueDate>></IssueDate>
	<IssueTime><<ALLTRIM(This.IssueTime)>></IssueTime>
	<InvoiceTypeCode><<This.InvoiceTypeCode>></InvoiceTypeCode>
	<CustomizationID><<This.OCustomizationID>></CustomizationID>
	<ID><<ALLTRIM(This.pid)>></ID>
	<DocumentCurrencyCode><<This.DocumentCurrencyCodeb>></DocumentCurrencyCode>
	<InvoicePeriod>
      <StartDate></StartDate>
      <StartTime></StartTime>
      <EndDate></EndDate>
	  <EndTime></EndTime>
	</InvoicePeriod>
	<AccountDocument>
		<ID><<ALLTRIM(This.pid)>></ID>
	</AccountDocument>
	<OrderReference>
		<ID></ID>
		<IssueDate></IssueDate>
	</OrderReference>
	<DespatchDocumentReference>
		<ID></ID>
		<IssueDate></IssueDate>
	</DespatchDocumentReference>
	<ReceiptDocumentReference>
		<ID></ID>
		<IssueDate></IssueDate>
	</ReceiptDocumentReference>
	<AdditionalDocumentReference>
		<ID></ID>
		<IssueDate></IssueDate>
		<DocumentTypeCode></DocumentTypeCode>
	</AdditionalDocumentReference>
	<PEDReference></PEDReference>
	<AAJReference></AAJReference>
	<AccountingCostCode></AccountingCostCode>
	<!-- Datos del emisor -->
	<AccountingSupplierParty>
		<AdditionalAccountID><<This.AdditionalAccountID>></AdditionalAccountID>
			<Party>
				<IndustryClasificationCode><<ALLTRIM(This.IndustryClasificationCode)>></IndustryClasificationCode>
				<PartyIdentification><<This.PartyIdentification>></PartyIdentification>
				<ID><<ALLTRIM(This.PartyID)>></ID>
				<schemeID><<This.PartyschemeID>></schemeID>
					<PartyName>
						<Name><<This.pname>></Name>
					</PartyName>
					<PhysicalLocation>
					<Address>
						<ID><<This.AddressId>></ID>
						<CityName><<This.CityName>></CityName>
						<PostalZone><<This.PostalZone>></PostalZone>
						<CountrySubentity><<ALLTRIM(This.CountrySubentity)>></CountrySubentity>
						<CountrySubentityCode><<This.CountrySubentityCode>></CountrySubentityCode>
						<AddressLine>
							<Line><<This.lineemisor>></Line>
						</AddressLine>
						<Country>
							<IdentificationCode><<This.CountryIdentificationCode>></IdentificationCode>
							<Name><<This.CountryName>></Name>
						</Country>
					</Address>
					</PhysicalLocation>
					<WebSite><<This.WebSite>></WebSite>
					<PBX><<This.PBX>></PBX>
				<PartyTaxScheme>
					<RegistrationName><<This.RegistrationName>></RegistrationName>
				    <TaxLevelCode><<This.TaxLevelCode>></TaxLevelCode>
				     <TaxScheme>
						  <ID><<This.TaxSchemeId>></ID>
						  <Name><<This.TaxSchemeName>></Name>
					 </TaxScheme>
				</PartyTaxScheme>
				<SellerContact>
					<ID><<This.SellerContactId>></ID>
				    <Name><<This.SellerContactName>></Name>
				    <Telephone><<This.SellerContactTelephone>></Telephone>
				    <ElectronicMail><<This.SellerContactElectronicMail>></ElectronicMail>
				    <AddressLine>
				    	<Line></Line>
				    </AddressLine>
				</SellerContact>
		</Party>
	</AccountingSupplierParty>
	<!-- Datos de la sucursal del emisor -->
	<SellerSupplierParty>
		<ID></ID>
		<CorporateRegistrationScheme></CorporateRegistrationScheme>
		<Party>
			<PartyName>
				<Name></Name>
			</PartyName>
			<PhysicalLocation>
				<Address>
				    <ID></ID>
				    <CityName></CityName>
				    <PostalZone></PostalZone>
				    <CountrySubentity></CountrySubentity>
					<CountrySubentityCode></CountrySubentityCode>
					<AddressLine>
						<Line></Line>
					</AddressLine>
					<Country>
						<IdentificationCode></IdentificationCode>
						<Name></Name>
					</Country>
				</Address>
			</PhysicalLocation>
		</Party>
	</SellerSupplierParty>
	<!-- Datos del adquiriente -->
	<AccountingCustomerParty>
		<AdditionalAccountID><<This.TAdditionalAccountID>></AdditionalAccountID>
		<Party>
			<PartyIdentification><<This.TPartyIdentification>></PartyIdentification>
			<ID><<This.TID>></ID>
			<schemeID><<This.TschemeID>></schemeID>
			<PartyName>
				<Name><<This.TName>></Name>
			</PartyName>
			<PhysicalLocation>
				<Address>
					<ID><<This.TPhysicalLocationId>></ID>
					<CityName><<This.TPhysicalLocationCityName>></CityName>
					<PostalZone><<This.Tpostaterce>></PostalZone>
					<CountrySubentity><<This.TCountrySubentity>></CountrySubentity>
					<CountrySubentityCode><<This.TCountrySubentityCode>></CountrySubentityCode>
					<AddressLine>
						<Line><<This.TAddressLineLine>></Line>
					</AddressLine>
					<Country>
						<IdentificationCode><<This.tCountryIdentificationCode>></IdentificationCode>
						<Name><<This.tCountryName>></Name>
					</Country>
				</Address>
			</PhysicalLocation>
			<PartyTaxScheme>
				<RegistrationName><<This.TRegistrationName>></RegistrationName>
				<TaxLevelCode><<This.TTaxLevelCode>></TaxLevelCode>
				<TaxScheme>
					<ID><<This.TTaxSchemeID>></ID>
					<Name><<This.TTaxSchemeName>></Name>
				</TaxScheme>
				<CorporateRegistrationScheme><<This.TCorporateRegistrationScheme>></CorporateRegistrationScheme>
				<RegistrationAddress>
                    <ID><<This.TRegistrationAddressIdcod>></ID>
					<CityName><<This.TRegistrationAddressCityNamesuc>></CityName>
					<PostalZone><<This.TRegistrationAddresspostaterceSu>></PostalZone>
					<CountrySubentity><<This.TCountrySubentitysu>></CountrySubentity>
					<CountrySubentityCode><<This.Tdanecoddepsu>></CountrySubentityCode>
					<AddressLine>
						<Line><<This.TAddressLineLinesu>></Line>
					</AddressLine>
				    <Country>
				        <IdentificationCode><<This.CountryIdentificationCodesu>></IdentificationCode>
				        <Name><<This.tCountryNamesu>></Name>
					</Country>
				</RegistrationAddress>
			</PartyTaxScheme>
			<Person>
				<FirstName><<This.tPerson>></FirstName>
				<LastName><<This.TPersonsegnombre>></LastName>
				<MiddleName><<This.TPersonFirstName>></MiddleName>
			</Person>
			<Contact>
				<Name><<This.TContactName>></Name>
				<Telephone><<This.TContactTelephone>></Telephone>
				<Mobilephone><<This.TContactMobilephone>></Mobilephone>
				<ElectronicMail><<This.TContactElectronicMail>></ElectronicMail>
			</Contact>
			<ClientCode>
				<ID><<This.TClientCodeId>></ID>
			</ClientCode>
		</Party>
	</AccountingCustomerParty>
	<!-- Datos del lugar de entrega -->
	<Delivery>
		<ActualDeliveryDate><<This.TDeliveryActualDeliveryDate>></ActualDeliveryDate>
		<ActualDeliveryTime><<This.TDeliveryActualDeliveryTime>></ActualDeliveryTime>
		<PartyName>
			<Name><<This.TDeliveryActualPartyNameName>></Name>
		</PartyName>
		<PhysicalLocation>
			<Address>
				<ID><<This.TDeliveryActualdlAddressID>></ID>
				<CityName><<This.TDeliveryActualdlAddressCityName>></CityName>
				<PostalZone><<This.TDeliveryActualdlAddressCityPostalZone>></PostalZone>
				<CountrySubentity><<This.TDeliveryActualdlAddressCountrySubentity>></CountrySubentity>
				<CountrySubentityCode><<This.TDeliveryActualdlAddressCountrySubentityCode>></CountrySubentityCode>
				<AddressLine>
					<Line><<This.TDeliveryActualdlAddresslAddressLine>></Line>
				</AddressLine>
				<Country>
					<IdentificationCode><<This.TDeliveryActualdllCountryIdentificationCode>></IdentificationCode>
					<Name><<This.TDeliveryActualdllCountryName>></Name>
				</Country>
			</Address>
		</PhysicalLocation>
	</Delivery>
	<!-- Grupo para la información relacionada con la entrega -->
	<DeliveryTerms>
		<ID><<This.TDeliveryTermsEID>></ID>
		<SpecialTerms><<This.TDeliveryTermsSpecialTerms>></SpecialTerms>
		<LossRiskResponsibilityCode><<This.TDeliveryTermsLossRiskResponsibilityCode>></LossRiskResponsibilityCode>
		<LossRisk><<This.TDeliveryTermsLossRisk>></LossRisk>
		<IncotermNote><<This.TDeliveryTermsIncotermNote>></IncotermNote>
	</DeliveryTerms>
	<!-- Instrucciones de pago -->
	<PaymentMeans>
		<ID><<This.tPaymentMeansID>></ID>
		<PaymentMeansCode><<This.TPaymentMeansPaymentMeansCodet>></PaymentMeansCode>
		<PaymentDueDate><<This.TPaymentMeansPaymentDueDate>></PaymentDueDate>
		<PaymentID><<This.pPaymentMeansPaymentID>></PaymentID>
		<Note><<This.TPaymentMeansPaymentNote>></Note>
	</PaymentMeans>
	<!-- Anticipo -->
	<PrePaidPayment>
		<ID><<This.PrePaidPaymentID>></ID>
		<PaidAmount><<This.PrePaidPaymentPaidAmount>></PaidAmount>
		<ReceivedDate><<This.PrePaidPaymentReceivedDate>></ReceivedDate>
		<PaidDate><<This.PrePaidPaymentPaidDate>></PaidDate>
		<PaidTime><<This.PrePaidPaymentPaidTime>></PaidTime>
		<InstructionID><<This.PrePaidPaymentInstructionID>></InstructionID>
	</PrePaidPayment>
	<!-- Descuentos y/o Cargos Totales -->
	<AllowanceCharge>
		<ID><<This.AllowanceChargeID>></ID>
		<ChargeIndicator><<This.AllowanceChargeChargeIndicator>></ChargeIndicator>
		<AllowanceChargeReasonCode><<This.AllowanceChargeAllowanceChargeReasonCode>></AllowanceChargeReasonCode>
		<AllowanceChargeReason><<This.AllowanceChargeAllowanceAllowanceChargeReason>></AllowanceChargeReason>
		<MultiplierFactorNumeric><<This.AllowanceChargeAllowanceMultiplierFactorNumeric>></MultiplierFactorNumeric>
		<BaseAmount><<This.AllowanceChargeAllowanceBaseAmount>></BaseAmount>
		<Amount><<This.AllowanceChargeAllowanceAmount>></Amount>
	</AllowanceCharge>
	<!-- tasa de cambio directa -->
	<PaymentExchangeRate>
		<CalculationRate><<This.PaymentExchangeRateCalculationRate>></CalculationRate>
		<Date><<This.PaymentExchangeRatedate>></Date>
	</PaymentExchangeRate>
	<!-- tasa de cambio adicional -->
	<PaymentAlternativeExchangeRate>
		<SourceCurrencyCode><<This.PaymentAlternativeExchangeRateSourceCurrencyCode>></SourceCurrencyCode>
		<TargetCurrencyCode><<This.PaymentAlternativeExchangeRateTargetCurrencyCode>></TargetCurrencyCode>
		<CalculationRate><<This.PaymentAlternativeExchangeRateCalculationRate>></CalculationRate>
		<Date><<This.PaymentAlternativeExchangeRateDate>></Date>
	</PaymentAlternativeExchangeRate>
ENDTEXT
 
SET STEP ON
 
YlcText=STRCONV(lcText, 9,1034)
=STRTOFILE(YlcText,Lnumfactu,.T.)


UNA PARTE DEL ARCHIVO QUE ME GENERA ES:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?xml version="1.0" encoding="UTF-8"?>
<Invoice>
	<IssueDate>2020-02-24</IssueDate>
	<IssueTime>10:54:42-05:00</IssueTime>
	<InvoiceTypeCode>01</InvoiceTypeCode>
	<CustomizationID>10</CustomizationID>
	<ID>57945</ID>
	<DocumentCurrencyCode>COP</DocumentCurrencyCode>
	<InvoicePeriod>
      <StartDate></StartDate>
      <StartTime></StartTime>
      <EndDate></EndDate>
	  <EndTime></EndTime>
	</InvoicePeriod>
	<AccountDocument>
		<ID>57945</ID>
	</AccountDocument>
	<OrderReference>
		<ID></ID>
		<IssueDate></IssueDate>
	</OrderReference>
	<DespatchDocumentReference>
		<ID></ID>
		<IssueDate></IssueDate>
	</DespatchDocumentReference>
	<ReceiptDocumentReference>
		<ID></ID>
		<IssueDate></IssueDate>
	</ReceiptDocumentReference>
	<AdditionalDocumentReference>
		<ID></ID>
		<IssueDate></IssueDate>
		<DocumentTypeCode></DocumentTypeCode>
	</AdditionalDocumentReference>
	<PEDReference></PEDReference>
	<AAJReference></AAJReference>
	<AccountingCostCode></AccountingCostCode>
	<!-- Datos del emisor -->
	<AccountingSupplierParty>
		<AdditionalAccountID>1</AdditionalAccountID>
			<Party>
				<IndustryClasificationCode>4641</IndustryClasificationCode>
				<PartyIdentification>31</PartyIdentification>
				<ID>900356028</ID>
				<schemeID>9</schemeID>
					<PartyName>
						<Name>TEXTILES MARGARETEX S.A.S</Name>
					</PartyName>
					<PhysicalLocation>
					<Address>
						<ID>11001</ID>
						<CityName>BOGOTÁ, D.C.</CityName>
						<PostalZone></PostalZone>
						<CountrySubentity>Bogotá</CountrySubentity>
						<CountrySubentityCode>11</CountrySubentityCode>
						<AddressLine>
							<Line>CL 19 68 A 20</Line>
						</AddressLine>
						<Country>
							<IdentificationCode>CO</IdentificationCode>
							<Name>Colombia</Name>
						</Country>

Y CUANDO VA A VALIDAR EL ARCHIVO ME SALE EL ERROR EN ESTA LINEA:
<CityName>BOGOTÁ, D.C.</CityName>

input is not proper UTF-8 indicate encoding

Yo pienso que es la tilde, pero se supone que la función me convierte a UTF-8, y reconoce los caracteres especiales, si alguien me puede colaborar con este error

Anexo imagen del error

atentamente

MARIAO
[email protected]
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

Conversión de archivo UTF-8 Con la función STRCONV

Publicado por José Velasco (1 intervención) el 29/07/2022 18:25:53
se deben transformar las letras con tilde o caracteres especiales, por ejemplo, en esta etiqueta de un documento electrónico, debía ir obligatoriamente con tilde, pero rechazaba por inválido:

'<contribuyenteRimpe>CONTRIBUYENTE RÉGIMEN RIMPE</contribuyenteRimpe>'

la solución fué colocarle lo siguiente y ya funcionó:

'<contribuyenteRimpe>CONTRIBUYENTE R'+CHR(195)+CHR(137)+'GIMEN RIMPE</contribuyenteRimpe>'

CHR(195)+CHR(137) = É

hay que buscar la tabla de conversiones, existen de algunos formatos, y se debe probar para ver la que te sirve

Saludos
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar