News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Macro lcase$

Started by clamicun, March 07, 2019, 12:50:41 AM

Previous topic - Next topic

aw27

Quote from: jj2007 on March 07, 2019, 09:40:43 PM
The interesting bit is that my exe sets the codepage to 65001 (=Utf8). However, it seems that on your machine it fails to do so - your chcp without args returns 1252. When I launch my exe and do a chcp directly after, it will show 65001.

Don't assume I will learn Masm Basic, I inserted this in your code
invoke crt_system, chr$("chcp")
and it displayed Active code page: 1252


clamicun

Jochen,
My rotine searches in strings from a fairly large database.

This is what I get:

Too many strings: check if local or register
Let x$= get cleared, or increase MbHeapStrings

HSE

JJ:
something it's not working!

Pasting result it's perfect (perhaps you are seen screen capture in RichMasm?):
D:\masm32\foro\clamicun>chcp
P gina de c¢digos activa: 850

D:\masm32\foro\clamicun>ascii3
äöü
German umlauts: ÄÖÜß - and some more: ÉÊÈÆÌÍÎÏÒÓÔÕÖØÙÚÛÜÁÂÀÃÅÞÍÎÌÏÑÓÔÒÕÚÛÙ - ????? ??????????
german umlauts: äöüß - and some more: éêèæìíîïòóôõöøùúûüáâàãåþíîìïñóôòõúûù - ????? ??????????
german umlauts: äöüß - and some more: éêèæìíîïòóôõöøùúûüáâàãåþíîìïñóôòõúûù - ????? ??????????
GERMAN UMLAUTS: ÄÖÜß - AND SOME MORE: ÉÊÈÆÌÍÎÏÒÓÔÕÖØÙÚÛÜÁÂÀÃÅÞÍÎÌÏÑÓÔÒÕÚÛÙ - ????? ??????????
D:\masm32\foro\clamicun>chcp
Página de códigos activa: 1252


But what I really see in the console it's not:

(For a moment I think problem was solved, but not)
Equations in Assembly: SmplMath

nidud

#18
deleted

clamicun

AW,
german.zip
_main.cpp
doesn't compile

E:\Dev-Cpp\_Examples\collect2.exe   [Error] ld returned 1 exit status

jj2007

@HSE, AW: What do you see when you do
chcp 65001
chcp
?

Quote from: clamicun on March 07, 2019, 09:52:33 PM
Wie leite ich den Consolentext in eine andere Variable um ?
Lower$(esi) allein gibt den Fehler "Syntaxerror Use_Let"

Let esi=Lower$(esi)

Quote from: clamicun on March 07, 2019, 11:01:59 PM
Too many strings: check if local or register
Let x$= get cleared, or increase MbHeapStrings

This means you are using Let esi="something" improperly. The reason is that Let esi="..." checks if esi points already to a heap location; if yes, it gets reallocated, fine. If not, a new one is being created - and there is a total of only 100 slots. So somewhere in your code you are using esi for other purposes. A simple lodsb or inc esi discards the pointer and forces Let to create a new one:

include \masm32\MasmBasic\MasmBasic.inc
  Init
  For_ ecx=1 To 200
        Let esi=Str$("THIS IS STRING #%i", ecx)
        Let esi=Lower$(Mid$(esi, 8 ))
        ; inc esi               ; very bad idea - this discards the pointer to heap memory
  Next
  Inkey "The last one: ", esi
EndOfCode


I would have to see your relevant code to find the problem. One way out is a global variable:
.DATA?
my$ dd ?
.CODE
Let my$="whatever "+my$+" etc"

aw27

Quote from: clamicun on March 08, 2019, 02:10:57 AM
AW,
german.zip
_main.cpp
doesn't compile

E:\Dev-Cpp\_Examples\collect2.exe   [Error] ld returned 1 exit status
I don't use in Windows, Linux tools, so can't figure out what the returned 1 exit status means.
Make a new console project in Visual Studio, copy what is in _main.cpp and paste in the initial source file you have.
You should be good to build.

aw27

@JJ
chcp 65001 always switches code page for every Windows version for the last 20 years.

HSE

Solved  :biggrin:

Quote from:  M$Note that successfully displaying Unicode characters to the console requires the following:

  • The console must use a TrueType font, such as Lucida Console or Consolas, to display characters.

  • A font used by the console must define the particular glyph or glyphs to be displayed. The console can take advantage of font linking to display glyphs from linked fonts if the base font does not contain a definition for that glyph.
I changed the font and German characters suddenly appear!

Equations in Assembly: SmplMath

nidud

#24
deleted

HSE

Equations in Assembly: SmplMath

aw27

In this case, it is possible to solve without Unicode and for anyone (not only for Germans)  only condition is the string stored in CP 1252 (may eventually also work when stored in other code pages like 850 and making adjustments, but did not confirm).


#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <locale.h>
#include <stdint.h>
#include <Windows.h>

// Assuming the string is in ANSI (CP 1252)
char * strMB = "GRÜEßEN ÖLTANKER ÄCHTUNG";
#define _LEN_ 30

int main()
{
_locale_t loc;
int len, i;
char LowerCase[_LEN_];

len = strlen(strMB);

loc = _create_locale(LC_ALL, "German");

for (i = 0; i <= len; i++) {
LowerCase[i] = _tolower_l(strMB[i], loc);
}

SetConsoleOutputCP(1252);
printf("%s\n", LowerCase);

_getch();
return 0;
}



nidud

#27
deleted

aw27

Quote from: nidud on March 08, 2019, 07:21:21 AM
It is this which make the whole thing so mind boggling.

That will work for all people that work with CP 1252 in Windows for non-Unicode, because Germans also use CP 1252, but it will still be necessary SetConsoleOutputCP(1252) or System("chcp 1252") if the CP of the console is not 1252.

clamicun

Thanka lot guys,
I'll check it out.

;=====================
Jochen,
I think I understand what you mean.
Within my search routine - bevor and after Let esi=Lower$(edi) - esi is very frequently used with different offsets.
I am not going to change this. It works perfectly since years.

Three days ago I wanted to make the routine not case sensitiv changing the haystack and the needle to lower case letters and realized that lcase$(offset string) is not going to do the job on Ü Ä Ö.
Of course it would be nicer if it worked not case sensitiv.