GithubHelp home page GithubHelp logo

Comments (9)

iisaxin avatar iisaxin commented on September 21, 2024 1

我的英语不太好,请尽量仔细的看懂我的话,
我的意思是你的dwg的文件版本太高,
你试试读取r2000版本的文件看看问题是否存在

from libredwg.

rurban avatar rurban commented on September 21, 2024

You are confused. >+ R2007 all text values are Windows unicode (i.e UCS-2),
With the rest you are also apparently confused. internal Dwg_Object * addresses are not offsets into the file.

from libredwg.

IdoGuzi avatar IdoGuzi commented on September 21, 2024

Thanks for answering rurban.
trying to get the text as 16 bit chars works now, I'm happy it's not a bug.
Is there a place in the documentation taking about the text format?

As I said in the post I'm on version 0.12.5 and I see the member's type has changed but the comment is the same.
quoting: "byte offset in the file".

size_t address; /*!< byte offset in the file */

Can you please briefly explain to what this address is pointing.

from libredwg.

rurban avatar rurban commented on September 21, 2024

Dwg_Object *obj->address is indeed the byte offset. But you were talking about the obj ptr, not obj->address.

The docs at https://www.gnu.org/software/libredwg/manual/LibreDWG.html#Types mentions

BITCODE_TU wchar*
length + windows 2-byte wchar string (UCS-2). The default text type since r2007.

I.e. all T types are TU since r2007, else TV,

from libredwg.

IdoGuzi avatar IdoGuzi commented on September 21, 2024

From the start I meant the obj.address, probably language barrier (I'm not a native English speaker).
I printed the address like this (looping over all dwg_objects):
printf("size: %d, address: %d\n", object.size, object.address);
and got: 193, 275739
and later ran

int test(void) {
	unsigned int size = 193;
	unsigned int address = 275739;
	char buf[size];
	int fd = open("my_file.dwg", O_RDONLY);
	printf("fd: %d\n", fd);
	int err = pread(fd, (void *)buf, size, address);
	close(fd);
	if (err < 0) {
		printf("failed to read mtext raw data, what: %s\n", strerror(err));
		return err;
	}
	printf("bytes read: %d\n", err);
	printf("size: %d, address: %d, raw data: %s\n\n\n", size, address, buf);
	return 0;
}

pread returns 0 for all mtexts byte offset in the file (by pread docs it means EOF).
can you see any problem with the way I tried to get out data?

from libredwg.

rurban avatar rurban commented on September 21, 2024

od --skip-bytes=275739 --read-bytes 193 my_file.dwg would be easier.
dwgread -v5 my_file.dwg would also be useful, as it converts your mtext value to utf-8

from libredwg.

IdoGuzi avatar IdoGuzi commented on September 21, 2024

It's easier (thanks), but as I expected od gives:
od: cannot skip past end of combined input

from libredwg.

iisaxin avatar iisaxin commented on September 21, 2024

Try changing your dwg version to r2000,
Too high version to work properly

from libredwg.

IdoGuzi avatar IdoGuzi commented on September 21, 2024

Try changing your dwg version to r2000,
Too high version to work properly

I'm guessing you are talking about the object byte offset.
The thing is it looks like the file is parsed correctly, so I don't think it's a version problem.
After @rurban explained that the text isn't utf-8 (and it was a rookie mistake on my part) I'm extracting the text and all the other values just fine.
The only problem I see is with the byte offset, though this problem doesn't affect my work, I would like to help make sure there's not a bug here.

from libredwg.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.